October 9, 2009 at 7:37 am
Hello all! I am brand new to this forum, so my apologies in advance for any breach of etiquette. :blush:
I have been using SQL Server 2005 for a few months now. In a previous life, I spent a lot of time with Oracle SQL. In Oracle, there is a command--SET ECHO ON. This is incredibly useful. When running a large batch of code, the actual lines being executed are shown on the screen before each result.
So for example, instead of seeing just:
(3648 row(s) affected)
(14483 row(s) affected)
You'd see the chunks of code displayed before each line. This is sort of a silly example, but if you had dozens and dozens of statements, you can see how it would be useful. Very useful indeed!
Anyway, SET ECHO ON doesn’t work in SQL Server 2005. Is there anything that does?
Thanks in advance for any help!
Zack
October 9, 2009 at 8:35 am
In SSMS you can go to Tools -> Options -> Query Results and in the Results to Grids/Text there is an option to include the query in the result set.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 9, 2009 at 9:01 am
Thanks so much! I wasn't aware that these options existed. This does help somewhat in that it shows the entire block of code prior to all the results. But it doesn't actually show the specific code just prior to the specific result. For example:
Here are 3 UPDATE statements:
Update TABLE set FIELD1 = 1;
Update TABLE set FIELD2 = 2;
Update TABLE set FIELD3 = 3;
What I want to see is:
Update TABLE set FIELD1 = 1;
(500 row(s) affected)
Update TABLE set FIELD2 = 2;
(500 row(s) affected)
Update TABLE set FIELD3 = 3;
(500 row(s) affected)
Setting this option gives me:
/*------------------------
Update TABLE set FIELD1 = 1;
Update TABLE set FIELD2 = 2;
Update TABLE set FIELD3 = 3;
------------------------*/
(500 row(s) affected)
(500 row(s) affected)
(500 row(s) affected)
Any other ideas? Is there anything that can be set within the code itself? Again, THANKS!
October 9, 2009 at 9:08 am
Sorry, there is nothing else I can think of.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 9, 2009 at 9:18 am
AFAIK, there isn't a way to do this. You could print the query
Update TABLE set FIELD1 = 1;
print 'Update TABLE set FIELD1 = 1;'
Update TABLE set FIELD2 = 2;
print 'Update TABLE set FIELD2 = 2;'
Update TABLE set FIELD3 = 3;
print 'Update TABLE set FIELD3 = 3;'
March 22, 2016 at 9:39 am
This request may be and old one but I have found a solution to the query.
Go to Query -> Query Options
Select Text in the Results tree on the Opened windows
Tick Include the query in the Result set
Press OK
Select Query ->Results to You may choose either Results to Text or Results to file.
You will see your query, data output and final statement how-many rows effected on the same view
Regards , Shaamil.
August 5, 2016 at 4:37 am
ok, thank you for sharing
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply