set show_sqltext allows you to print the SQL text for ad hoc queries, stored procedures, cursors, and dynamic prepared statements.
You need not enable set show_sqltext before you execute the query (as you do with commands like set showplan on) to collect diagnostic information for a SQL session. Instead, you can enable it while the commands are running to help determine which query is performing poorly.
dbcc traceon(3604)The syntax for set show_sqltext is:
set show_sqltext {on | off}
set show_sqltext on
Once set show_sqltext is enabled, all SQL text is printed to stdout for each command or system procedure you enter. Depending on the command or system procedure you run, this output can be extensive.
To disable show_sqltext, enter:
set show_sqltext off