This is a petty question, but is such a pain for me. Often, I will write store procedures with multiple queries in them. To make debugging easier, I write it like so:
print 'Some notes about query 1'
select * from someTable
print 'some notes about query 2'
update sometable set column = null
then I get results like this:
Some notes about query 1
(8 row(s) affected)
Some notes about query 2
(8 row(s) affected)
They way it spaces itself makes it hard to read. I'd want the results to look like this:
Some notes about query 1
(8 row(s) affected)
Some notes about query 2
(8 row(s) affected)
I know its petty, but it irks me. Anyone have any thoughts?
Putting together the answers you get:
--Set up test data
DECLARE @someTable AS TABLE(id int identity, somevalue int)
INSERT INTO @someTable (somevalue) VALUES (1)
INSERT INTO @someTable (somevalue) VALUES (2)
INSERT INTO @someTable (somevalue) VALUES (3)
INSERT INTO @someTable (somevalue) VALUES (4)
INSERT INTO @someTable (somevalue) VALUES (5)
INSERT INTO @someTable (somevalue) VALUES (6)
INSERT INTO @someTable (somevalue) VALUES (7)
INSERT INTO @someTable (somevalue) VALUES (8)
--Here's the method.
SET NOCOUNT ON --As kd7 said this will get rid of spaces. Along with the rowcount.
print 'Some notes about query 1'
select * from @someTable
print '(' + CONVERT(varchar,@@rowcount) +' row(s) affected)'--This adds the row count back in
print '' --Formatting row to add the space you require.
print 'Some notes about query 2'
update @sometable set somevalue = null
print '(' + CONVERT(varchar,@@rowcount) +' row(s) affected)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With