Char (9) does not print tab on Sql 2005 server

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

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

But it does not work and always prints

 tab--> <--tab 

Is there something I don't see?

+7
source share
3 answers

If you test this inside Studio Management, the Results to Grid parameter ( Ctrl + D ) will change your tab to a space ... try switching to Results to Text ( Ctrl + T ) and you will see a tab.

Alternatively, you can change select to print :

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

Outlets ...

 tab--> <--tab 
+10
source

The thing about tabs is that they are not a constant width. The tab character says: "Lead me to the next tab." If you currently have stop quotes with eight characters and the tab with a six character, the tab will be only one width. But let me say that you are skeptical (good!). There is more evidence that the tab is actually being displayed. If you do something like print '>' + char(9) + '<' , you will notice that you cannot select only one space in the space, indicating that the space you see is atomic. But more convincing for me is pasting it into an editor that allows you to see tabs. I use vim but use what you like. In all the cases that I tested, a tab character appeared.

0
source

Each Char(9) or char(160) converted to a space. If you align char (9) + char (9) + char (9) =>, you still get only 1 space.

So I tried:

 <"something"+char(9)+char(160)+char(9)+char(160)+char(9)+char(160)+char(9)+char(160)"something"> 

returns something[8 spaces here]something (each char9 or char16 is replaced by a space)

Visually, I got what I wanted ...

0
source

All Articles