以下是我尝试在SQL Management Studio 2008 R2上运行的查询:
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
这是我的屏幕上的完整错误:
The SELECT permission was denied on the object 'sysaltfiles', database 'mssqlsystemresource', schema 'sys'.
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.
看起来权限搞砸了。但我无法弄清楚该怎么做。请一步一步的指导,一个很好解释的答案将非常感谢。谢谢!
答案 0 :(得分:0)
输入所有域名到数据源的连接字符串... data source = dbname.doma.main.local