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: Thursday, May 1, 2014 2:22 PM
Points: 24, Visits: 94
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 @ 5:47 PM
Points: 12,910, Visits: 32,020
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


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, August 29, 2014 2:32 PM
Points: 13,302, Visits: 12,168
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
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1038504
Posted Wednesday, December 22, 2010 2:23 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, August 29, 2014 2:32 PM
Points: 13,302, Visits: 12,168
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
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1038505
Posted Wednesday, December 22, 2010 2:23 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:20 PM
Points: 7,161, Visits: 13,229
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: Thursday, May 1, 2014 2:22 PM
Points: 24, Visits: 94
Worked. Thanks!
Post #1038509
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse