CREATE DATABASE使用默认路径中的文件 [英] CREATE DATABASE using file in default path

查看:763
本文介绍了CREATE DATABASE使用默认路径中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个创建数据库的SQL脚本。现在,我有这个:

I want to create an SQL script that creates a database. Right now, I have this:

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

但是,这会产生以下错误:

However, this generates the following error:

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.

我知道问题是我没有为文件名指定完全限定路径。但是我想要能够运行这个脚本,而不管数据库服务器的目录结构。

I know the problem is that I did not specify fully qualified path for the filenames. But I want to be able to run this script regardless of the directory structure of the database server. Is there some way to use a default path?

推荐答案

您可以创建一个不指定文件详细信息的数据库,例如:

You can create a database without specifying file details, like:

CREATE DATABASE文件;

CREATE DATABASE Documents;

这篇关于CREATE DATABASE使用默认路径中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆