Kye
Kye

Reputation: 6289

How to alter the SQL output messages

I have multiple INSERT / SELECT statements as part of a single SQL data import script. When I run my script I get the output

(141926 row(s) affected)

(124366 row(s) affected)

(4 row(s) affected)

(1 row(s) affected)

But what I would really want is

(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)

Is there anyway to do this in SQL??

Upvotes: 0

Views: 213

Answers (1)

DeanOC
DeanOC

Reputation: 7282

I agree with @yorick de Wid, in that I don' think you can customise the SQL output.

The closest that I can think of in SQL Server is to "roll your own", by doing something like:

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

Upvotes: 2

Related Questions