October 6, 2009 at 10:40 am
Hi all,
This is for SQL 2000. I am trying to add a tab character to a string using char(9) but all I get is a single space.
Example:
select 'there should be a tab between here' + char(9) + 'and here'
Ideas?
Thanks.
October 6, 2009 at 10:56 am
What are you using to verify that you only get a space? You're not going to see it in QA or SSMS, as they don't show things like carriage returns/tabs/etc. If you select that cell into a front end that does display those things, it may work fine.
October 6, 2009 at 11:06 am
Ahh, I was only looking in QA then copy/paste to Notepad. The finished output does have the tab.
Thanks.
October 6, 2009 at 9:26 pm
RD-201664 (10/6/2009)
select 'there should be a tab between here' + char(9) + 'and here'Ideas?
declare @result varchar(100)
set @result = 'TEST START'+char(9)+'EXEC'+char(9)+'TEST END'
select @result
RESULT
TEST STARTEXECTEST END
set @result = replace(@result,char(9),' -TAB HERE- ')
select @result
RESULT
TEST START -TAB HERE- EXEC -TAB HERE- TEST END
March 13, 2013 at 4:44 am
[font="Arial"]I add the same problem with SQL Server :
"something"+char(9)+"something"
returns something something
"something"+char(9) + char(9)+char(9)+char(9)+char(9)+char(9)+"something"
returns something something
finally, I "cheated" with :
"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)
so visually I got what I wanted, even if I admit it is not very elegant...[/font]
May 11, 2017 at 11:06 am
I solved this by just creating a blank tab column, then copying both columns. It pastes perfectly with a tab.
SELECT '' AS Tab, 'Text following tab.' AS OtherText
I use this method when I want to generate well-tabbed SQL code.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply