0

现在这里是我试图运行的查询来执行一个脚本,该脚本将根据脚本构建我的数据库:

USE master
GO
if exists (select * from sysdatabases where name='Northwind')
        drop database Northwind
go

DECLARE @device_directory NVARCHAR(520)
SELECT @device_directory = SUBSTRING(filename, 1, CHARINDEX(N'master.mdf', LOWER(filename)) - 1)
FROM master.dbo.sysaltfiles WHERE dbid = 1 AND fileid = 1

EXECUTE (N'CREATE DATABASE Northwind
  ON PRIMARY (NAME = N''Northwind'', FILENAME = N''' + @device_directory + N'northwnd.mdf'')
   LOG ON (NAME = N''Northwind_log'',  FILENAME = N''' + @device_directory + N'northwnd.ldf'')')
go

exec sp_dboption 'Northwind','trunc. log on chkpt.','true'
exec sp_dboption 'Northwind','select into/bulkcopy','true'
GO

现在这是我得到的错误......

Msg 262, Level 14, State 1, Line 1
CREATE DATABASE permission denied in database 'master'.
Msg 15010, Level 16, State 1, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Supply a valid database name. To see available databases, use sys.databases. 

Msg 15010, Level 16, State 1, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Supply a valid database name. To see available databases, use sys.databases. 

请帮忙!数据库现在应该在 master 中创建,但不是!

4

1 回答 1

0

您应该拥有创建新数据库的 CREATE DATABASE 权限。如果您不熟悉此主题,请尝试以“sa”用户身份登录(如果您知道密码),或要求管理员将您的登录名添加到 SQL Server 中的“sysadmin”角色。

于 2013-07-19T07:36:32.590 回答