J
jialiguo
Unregistered / Unconfirmed
GUEST, unregistred user!
use master
IF not EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'ba2004')
begin
CREATE DATABASE [ba2004]
ON (NAME = N'ba2004_Data', FILENAME = N'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Data.MDF' , SIZE = 16, FILEGROWTH = 10%)
LOG ON (NAME = N'ba2004_Log', FILENAME = N'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Log.LDF' , SIZE = 56, FILEGROWTH = 10%)
COLLATE Chinese_PRC_CI_AS
end;
RESTORE DATABASE ba2004 FROM DISK = 'D:/巡逻备份数据/BAK5BA2004.BAR'
go
use master '
+'IF not EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'''+Bname+''') '
+' begin '
+' CREATE DATABASE '''+Bname+''' '
+' ON (NAME = N'''+Bname+'_Data'+''', FILENAME = N'''+'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Data.MDF'+''' , SIZE = 16, FILEGROWTH = 10%) '
+' LOG ON (NAME = N'''+Bname+'_Log'+''', FILENAME = N'''+'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Log.LDF'+''' , SIZE = 56, FILEGROWTH = 10%) '
+' COLLATE Chinese_PRC_CI_AS '
+' end; '
+' RESTORE DATABASE '''+Bname+''' FROM DISK = '''+dir_B+Bname+'.BAR'+'''';
2种写法,一个是死的,一个是活的,活的报错,错在哪?
IF not EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'ba2004')
begin
CREATE DATABASE [ba2004]
ON (NAME = N'ba2004_Data', FILENAME = N'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Data.MDF' , SIZE = 16, FILEGROWTH = 10%)
LOG ON (NAME = N'ba2004_Log', FILENAME = N'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Log.LDF' , SIZE = 56, FILEGROWTH = 10%)
COLLATE Chinese_PRC_CI_AS
end;
RESTORE DATABASE ba2004 FROM DISK = 'D:/巡逻备份数据/BAK5BA2004.BAR'
go
use master '
+'IF not EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'''+Bname+''') '
+' begin '
+' CREATE DATABASE '''+Bname+''' '
+' ON (NAME = N'''+Bname+'_Data'+''', FILENAME = N'''+'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Data.MDF'+''' , SIZE = 16, FILEGROWTH = 10%) '
+' LOG ON (NAME = N'''+Bname+'_Log'+''', FILENAME = N'''+'C:/Program Files/Microsoft SQL Server/MSSQL/data/ba2004_Log.LDF'+''' , SIZE = 56, FILEGROWTH = 10%) '
+' COLLATE Chinese_PRC_CI_AS '
+' end; '
+' RESTORE DATABASE '''+Bname+''' FROM DISK = '''+dir_B+Bname+'.BAR'+'''';
2种写法,一个是死的,一个是活的,活的报错,错在哪?