我有一个大的(1.2GB)sql(服务器)脚本文件,其中包含许多存储过程。我想执行这个大文件。第一个问题是我无法在SQL Server Management Studio中打开该文件。所以,我尝试了以下代码:
declare @FileName varchar(255)
declare @SQLLoad nvarchar(max)
-- Set the file to load SQL Script from
set @FileName = 'C:\ZarifBarDB.sql'
-- Create command to load and execute the file
set @SQLLoad =
N'declare @cmd varchar(max);
select @cmd = fd.col1
from openrowset(bulk ' + QUOTENAME(@FileName, '''') + ', SINGLE_NCLOB) as FD(col1);
exec (@cmd)'
-- Load file data and execute
exec (@SQLLoad)
我应该删除所有“GO”语句才能执行此查询。但是这样,当执行到达“Create Procedure”命令时,我收到以下错误:
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
我该怎么办?