Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Manipulate String Expand / Collapse
Author
Message
Posted Wednesday, December 22, 2010 1:59 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, April 05, 2013 2:15 PM
Points: 20, Visits: 83
I have several value in a column called test.

Select Statement: Select Test From Abc
Output: JonDoe

Desired Output: 'JonDoe'

How do I achieve desired output?
Post #1038484
Posted Wednesday, December 22, 2010 2:22 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:33 PM
Points: 11,648, Visits: 27,768
JStevenson1 (12/22/2010)
I have several value in a column called test.

Select Statement: Select Test From Abc
Output: JonDoe

Desired Output: 'JonDoe'

How do I achieve desired output?


so the only difference is you want single quotes around the field, right?
this is pretty straight forward, what have you tried so far?

I hate to give it away in case this is a homework question, so let me give some hints first:
are you familiar with how to concatenate strings together in a select statement?


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1038503
Posted Wednesday, December 22, 2010 2:22 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 1:17 PM
Points: 8,641, Visits: 8,273
JStevenson1 (12/22/2010)
I have several value in a column called test.

Select Statement: Select Test From Abc
Output: JonDoe

Desired Output: 'JonDoe'

How do I achieve desired output?


Are you wanting to add the single quote around the field?



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1038504
Posted Wednesday, December 22, 2010 2:23 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 1:17 PM
Points: 8,641, Visits: 8,273
JINX! I too assumed this to be homework. ;)

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1038505
Posted Wednesday, December 22, 2010 2:23 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 24, 2013 3:17 PM
Points: 6,731, Visits: 12,131
JStevenson1 (12/22/2010)
I have several value in a column called test.

Select Statement: Select Test From Abc
Output: JonDoe

Desired Output: 'JonDoe'

How do I achieve desired output?


Something like the following code? (assuming all you want to do is add the quotation marks...)
Select ''''+Test +'''' From Abc





Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1038506
Posted Wednesday, December 22, 2010 2:27 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, April 05, 2013 2:15 PM
Points: 20, Visits: 83
Worked. Thanks!
Post #1038509
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse