嗨,我是綁來運行ALTER DATABASE語句,並不斷收到錯誤: (這是一個腳本,將運行鍼對多個數據庫去)語法問題,使用alter database和set命令
SELECT is_broker_enabled FROM sys.databases WHERE name = db_name()
DECLARE @SQL NVARCHAR(1024)
IF (SELECT is_broker_enabled FROM sys.databases WHERE name = db_name()) = 0
BEGIN
SET @SQL = N'ALTER DATABASE [' + db_name() + '] SET SINGLE_USER WITH ROLLBACK IMMEDIATE';
SELECT @SQL;
sp_executesql @SQL;
SET @SQL = N'ALTER DATABASE [' + db_name() + '] SET ENABLE_BROKER';
SELECT @SQL;
sp_executesql @SQL;
SET @SQL = N'ALTER DATABASE [' + db_name() + '] SET MULTI_USER';
SELECT @SQL;
sp_executesql @SQL;
END
SELECT is_broker_enabled FROM sys.databases WHERE name = db_name()
我不斷收到
Msg 102, Level 15, State 1, Line 11 Incorrect syntax near 'sp_executesql'. Msg 102, Level 15, State 1, Line 15 Incorrect syntax near 'sp_executesql'. Msg 102, Level 15, State 1, Line 20 Incorrect syntax near 'sp_executesql'.
我做了愚蠢的事情 - 但像期待看到不產生大部分的語法問題...
dhhhhooooooooo ... – 2011-12-19 08:49:10