Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TAB being represented as a SPACE in the output

Status
Not open for further replies.
Mar 29, 2010
20
GB
Hi there,
I'm trying to insert a TAB into my output in SQL Server 2005 but it just represents it as a SPACE.
First I tried the following syntax with the TAB manually put in the string:
SELECT 'test1 test2'

And also using CHAR(9) like:
SELECT 'test1' + CHAR(9) + CHAR(9) + CHAR(9) + CHAR(9) + 'test2'

But neither work, the output I get in both cases just has spaces rather than tabs:
'test1 test2'

I've also tried doing it in the SSRS 2005 front end to no avail.

Any ideas?
 
You are getting a tab in the data. Unfortunately, when you use SSMS to view the output in "Grid" mode, it doesn't look like a tab. Try this: Click Query -> Results To -> Results to Text and then run the query again.


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
You're right I can now see the tabs correctly when viewing "Results to text", but I need the final output in SSRS, so the results need to be in grid format, SSRS doesn't seem to pick it up in text mode.

Thanks for the input though, I never realised it was doing it properly in text mode.
 
it doesn't really matter what format you set SSMS to output to since in SSRS, it will read the results from the sproc using it's own system.
As long as the tab is actually there in the data, then you should be looking at your actual report.

how is this data displayed/setup? It's probably some sort of formatting on your text box or tablix/cell that's making it display tabs as space...

--------------------
Procrastinate Now!
 
Hi Crowley, I ran the full thing from start to finish and found some strange things, but it worked in the end for what I wanted, with some minor tweaking.
-SSMS 'Results to Text' worked
-SSMS 'Results to Grid' replaced tabs with spaces
-SSRS outputted a single space instead of the correct number of tabs when viewing it in SSRS
-SSRS exporting to CSV outputs the tabs but an incorrect number of tabs

So i put + '' between each CHAR(9) and it seemed to make it work when I output to CSV.

Since it's an exported csv that I need, i'll just stick with this method and not ask questions lol.

Thanks for the input, I probably wouldnt have checked through it all and come to this conclusion without it.
 
just to clarify, I said i put + '' between each CHAR(9) but on this forum it looks like a plus sign then a double quote mark, its actually 2 singles like ' ' with no space between them :]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top