參考腳本:
execute sp_addextendedproperty 'MS_Description','XXXX','user','dbo','table','TB1',null,null;
execute sp_addextendedproperty 'MS_Description','XXXX2','user','dbo','table','TB2',null,null;
在SSMS中執行的時候如果第1個報錯了,第2個不會執行被中斷了
只有這種才可以
execute sp_addextendedproperty 'MS_Description','XXXX','user','dbo','table','TB1',null,null;
GO
execute sp_addextendedproperty 'MS_Description','XXXX2','user','dbo','table','TB2',null,null;
但是我的陳述句都是SQL拼接出來的,沒法出現換行的GO
,改成
execute sp_addextendedproperty 'MS_Description','XXXX','user','dbo','table','TB1',null,null;GO
execute sp_addextendedproperty 'MS_Description','XXXX2','user','dbo','table','TB2',null,null;GO
訊息 102,級別 15,狀態 1,第 1 行
“GO”附近有語法錯誤。
訊息 102,級別 15,狀態 1,第 2 行
“GO”附近有語法錯誤。
uj5u.com熱心網友回復:
加上 try catch 就可以了:--1.
BEGIN TRY
execute sp_addextendedproperty 'MS_Description','XXXX','user','dbo','table','TB1',null,null;
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS ErrorMessage
END CATCH
--2.
BEGIN TRY
execute sp_addextendedproperty 'MS_Description','XXXX2','user','dbo','table','TB2',null,null;
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS ErrorMessage
END CATCH
uj5u.com熱心網友回復:
用;(分號)呢
DECLARE @SQL VARCHAR(1000)
SET @SQL='execute sp_addextendedproperty ''MS_Description'',
''接收時間'',
''user'', ''dbo'', ''table'', ''BS_Track_Info'', ''column'', ''RecieveTime'';
execute sp_addextendedproperty ''MS_Description'',
''接收時間'',
''user'', ''dbo'', ''table'', ''BS_Track_Info'', ''column'', ''RecieveTime'';
execute sp_addextendedproperty ''MS_Description'',
''主鍵'',
''user'', ''dbo'', ''table'', ''BS_Track_Info'', ''column'', ''id'''
exec(@SQL)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/283401.html
標籤:基礎類
上一篇:mysql資料在匯入時如何去重的問題(通過LOAD DATA INFILE方式)
下一篇:求大佬解答這題
