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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 comma seperated string value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ersantosh1
Starting Member

India
6 Posts

Posted - 04/20/2012 :  10:38:20  Show Profile  Reply with Quote
Hi,
i got resultstring like lsresult=107,108,109,110 those are template ids

whose names i have to get in following fashion...

lsnames = GEN,VEN,TEN,SEN

i have query like

select TEM_NAME FROM MST_TEMPLATE WHERE TEM_ID IN (107,108,109,110);

SHOULD I GET RESULT IN THIS FASHION lsTempName=GEN,VEN,TEN,SEN

becauese i have to use that variable on my Jsp page like <%=lsTempName%>

Plz help

Thanks
santosh

srahangdale

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 04/20/2012 :  11:49:36  Show Profile  Reply with Quote
quote:
SHOULD I GET RESULT IN THIS FASHION lsTempName=GEN,VEN,TEN,SEN

Are you asking whether that would be the format output of the select statement? If so, it won't be. The result will be four rows of data, rather than comma-separated result.

If you do want to make it comma-separated, you can use the xml path approach. For example, see this thread: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=173794
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 04/20/2012 :  15:32:18  Show Profile  Reply with Quote
quote:
Originally posted by ersantosh1

Hi,
i got resultstring like lsresult=107,108,109,110 those are template ids

whose names i have to get in following fashion...

lsnames = GEN,VEN,TEN,SEN

i have query like

select TEM_NAME FROM MST_TEMPLATE WHERE TEM_ID IN (107,108,109,110);

SHOULD I GET RESULT IN THIS FASHION lsTempName=GEN,VEN,TEN,SEN

becauese i have to use that variable on my Jsp page like <%=lsTempName%>

Plz help

Thanks
santosh

srahangdale


why bnot bring them as a resultset from sql and then generate comma seperated list from front end?
If not you've use UDF or use XML blaclbox method for generating csv
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/


Edited by - visakh16 on 04/20/2012 15:33:47
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.09 seconds. Powered By: Snitz Forums 2000