【发布时间】:2009-10-28 14:31:25
【问题描述】:
我想创建一个用于创建数据库的 SQL 脚本。现在,我有这个:
CREATE DATABASE [Documents] ON PRIMARY
( NAME = N'Documents', FILENAME = N'Documents.mdf')
LOG ON
( NAME = N'Documents_log', FILENAME = N'Documents_log.ldf')
COLLATE SQL_Latin1_General_CP1_CI_AS
但是,这会产生以下错误:
Msg 5105, Level 16, State 2, Line 2
A file activation error occurred. The physical file name 'Documents.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 1802, Level 16, State 1, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
我知道问题在于我没有为文件名指定完全限定的路径。但无论数据库服务器的目录结构如何,我都希望能够运行此脚本。有什么方法可以使用默认路径吗?
【问题讨论】:
标签: sql sql-server database