2014-10-31 75 views
0

我有多個INSERT/SELECT語句作爲單個SQL數據導入腳本的一部分。當我運行我的腳本,我得到的輸出如何更改SQL輸出消息

(141926 row(s) affected) 

(124366 row(s) affected) 

(4 row(s) affected) 

(1 row(s) affected) 

但是我真正想要的是

(141926 row(s) affected) - Customers Deleted 

(124366 row(s) affected) - Customers Inserted 

(4 row(s) affected) - Customers missing last name etc 

(1 row(s) affected) 

反正有沒有做到這一點的SQL?

+0

你不能真正改變在一般的輸出方式,因爲SQL只有查詢,結果的變化是數據庫管理層的一部分。也就是說,像pg/mssql這樣的數據庫確實允許這樣做。 – 2014-10-31 00:14:47

回答

2

我同意@yorick de Wid,因爲我不認爲你可以自定義SQL輸出。

,我能想到的在SQL Server是「滾你自己的」,通過做一些像最近的:

declare @recordsaffected int 
<execute your SQL statement here> 
set @recordsaffected = @@ROWCOUNT 
print convert(varchar,@recordsaffected) + ' <your message here>'