Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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 @ 4:13 PM
Points: 14,444, Visits: 37,856
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

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1038503
Posted Wednesday, December 22, 2010 2:22 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 2:55 PM
Points: 15,820, Visits: 16,192
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


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 2:55 PM
Points: 15,820, Visits: 16,192
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: Wednesday, February 10, 2016 11:50 AM
Points: 6,897, Visits: 13,559
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