Is there a TSQL statement to configure the output to be Text-Column aligned?

I want to use SQL templates for my coworkers to run some templated UPDATE before/after statements. But when they run the query it needs to output to text and Column delimited

enter image description here

So contrived example say I have this query:

USE master

FROM sys.dm_os_ring_buffers AS dorb
WHERE dorb.timestamp = N'<time, bigint, NULL>'

Is there a some SET statement to configure the output to be Text-Column aligned? This is only for these specific queries otherwise my coworker would want their default settings which is grid. I also can't rely on them to know to change it and that is important because unlike my contrived example they are print commands of sql update before/after statements.

Thus far I think my best bet would be to create a SSMS Add-in but I REALLY do not want to spend time doing that!

1 Answer 1


No, there is no programmatic way (outside of what you suggested: writing a custom SSMS plug-in) to control SSMS (for the most part). Like most commands, SET commands are executed by SQL Server. The only control you could have locally is a subset of the SQLCMD commands -- :r, :setvar, :connect, and so on -- but none of those allow for configuring the UI / SSMS.

BUT, all hope might not be lost yet. Since you are giving your coworkers T-SQL templates to copy and paste and fill out, and since there are already short-cut keys to toggle between "Results to Grid" and "Results to Text", just add in a few helpful comments to direct them on how to execute the script. Something along the lines of:


1) Control-Shift-M    (to fill out parameter values)
2) Control-T          (for Results To Text)
3) Control-E (or F5)  (to execute query)
4) Control-D          (for Results to Grid)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.