Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Char(9) doesn't print tab in Sql server 2005

I am trying to print a tab in sql server using:

select 'tab-->' + char(9) + '<--tab'

But it doesn't seem to work and always prints

tab--> <--tab

Is there any thing I am missing?

like image 536
shrekDeep Avatar asked Jul 23 '12 18:07

shrekDeep


People also ask

How do I select a tab in SQL?

Use the SQL tab to create an SQL WHERE clause to handle selection criteria that are more complex than can be defined on the Selection Criteria tab. For example, to select the appropriate set of data for a table, you might need a combination of AND and OR logical operators.


2 Answers

If you're testing this inside of Management Studio, the Results to Grid (Ctrl + D) setting will change your tab to a space... try switching to Results to Text (Ctrl + T) instead, and you will see the tab.

Alternately, you can change your select to a print:

print 'tab-->' + char(9) + '<--tab'

Outputs...

tab-->  <--tab
like image 72
Michael Fredrickson Avatar answered Sep 18 '22 17:09

Michael Fredrickson


  1. Tool -> Options -> Query Results -> SQL Server -> Results to Grid -> Retain CR/LF on copy or save
  2. Restart SSMS
like image 32
Dzmitry Paliakou Avatar answered Sep 19 '22 17:09

Dzmitry Paliakou