SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to get single quotes for every row ???
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mohan123
Constraint Violating Yak Guru

India
252 Posts

Posted - 02/05/2013 :  23:47:50  Show Profile  Reply with Quote
hello all,

i am havind the codes like this

48267
7998
51075
52220
57627
58772

is there any function or query

to make this codes

'48267'
'7998'
'51075'
'52220'
'57627'
'58772'

in mssql OR eXCEL ....Suggest me

P.V.P.MOhan

khtan
In (Som, Ni, Yak)

Singapore
17626 Posts

Posted - 02/06/2013 :  00:07:43  Show Profile  Reply with Quote
is that string or numbers ?

if it is string just simple
select '''' + string_column + '''' from yourtable


if it is numbers, you will have to convert to string frist
select '''' + convert(varchar(10), numbers_column) + '''' from yourtable



KH
Time is always against us

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/06/2013 :  00:13:16  Show Profile  Reply with Quote
nope. you've to write one

SELECT '''' + CAST(Column AS varchar(100)) + '''' FROM table

in case column is already of character type, you can dispense with the CAST part

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/06/2013 :  00:15:28  Show Profile  Reply with Quote
ah...didnt refresh

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mohan123
Constraint Violating Yak Guru

India
252 Posts

Posted - 02/06/2013 :  00:34:17  Show Profile  Reply with Quote
khtan and visakh it worked like charm.But i did this one in excel
by following this steps :
1) copied all rows in Excel column and beside columns i gave " quotes on both sides.

then copied in mssql and written LTRIM and RTRIM but your query is so accurate.I will use this one

P.V.P.MOhan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/06/2013 :  00:37:55  Show Profile  Reply with Quote
you can use both ways. i also use Excel for generating queries on the fly

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mohan123
Constraint Violating Yak Guru

India
252 Posts

Posted - 02/06/2013 :  00:40:45  Show Profile  Reply with Quote
Excel can be used to generate MSSQL queries????HOW

P.V.P.MOhan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/06/2013 :  00:55:40  Show Profile  Reply with Quote
copying data over sheet and then applying excel formulas to generate values on the fly

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22755 Posts

Posted - 02/08/2013 :  07:47:51  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Do it in EXCEL that will be very easy

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000