我想创建一个创建数据库的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
Run Code Online (Sandbox Code Playgroud)
但是,这会生成以下错误:
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.
Run Code Online (Sandbox Code Playgroud)
我知道问题是我没有为文件名指定完全限定的路径.但我想能够运行此脚本,无论数据库服务器的目录结构如何.有没有办法使用默认路径?