0

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??

Kye
  • 5,919
  • 10
  • 49
  • 84
  • You cannot really alter the output in a general way since SQL only queries, the results of the alterations are part of the database management layer. That said, some databases like pg/mssql do allow this. – Yorick de Wid Oct 31 '14 at 00:14

1 Answers1

2

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>'
DeanOC
  • 7,142
  • 6
  • 42
  • 56