SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Inserting TAB into string


Inserting TAB into string

Author
Message
RD-201664
RD-201664
SSC-Enthusiastic
SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)

Group: General Forum Members
Points: 134 Visits: 575
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.
Garadin
Garadin
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2923 Visits: 4107
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.

Seth Phelabaum
Consistency is only a virtue if you're not a screwup. ;-)

Links: How to Post Sample Data :: Running Totals :: Tally Table :: Cross Tabs/Pivots :: String Concatenation
RD-201664
RD-201664
SSC-Enthusiastic
SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)

Group: General Forum Members
Points: 134 Visits: 575
Ahh, I was only looking in QA then copy/paste to Notepad. The finished output does have the tab.
Thanks.
arun.sas
arun.sas
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1723 Visits: 3493
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 START EXEC TEST END

set @result = replace(@result,char(9),' -TAB HERE- ')
select @result


RESULT
TEST START -TAB HERE- EXEC -TAB HERE- TEST END
emich11-reseau
emich11-reseau
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 0
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...

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search