Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 rename column name in select stmt
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

svibuk
Yak Posting Veteran

62 Posts

Posted - 02/02/2013 :  07:38:49  Show Profile  Reply with Quote
select lang +',' from M_LANG l inner join  sel_lang s on l.LID=s.lcode  where mcode in('000001') for xml path('')

the output i get is
XML_F52E2B61-18A1-11d1-B105-00805F49916B
English,French,

but i need the output as
LAnguage
English,French,

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 02/02/2013 :  07:59:42  Show Profile  Reply with Quote
Wrap it in another select and give it an alias
SELECT (
   select lang +',' from M_LANG l inner join  sel_lang s on l.LID=s.lcode  where mcode in('000001') for xml path('')
   ) as Language
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/02/2013 :  08:01:54  Show Profile  Reply with Quote

SELECT Language 
FROM
(
SELECT STUFF((select lang +',' from M_LANG l inner join  sel_lang s on l.LID=s.lcode  where mcode in('000001') for xml path('')),1,1,'') AS Language
)t


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

Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 02/02/2013 :  08:05:00  Show Profile  Reply with Quote
quote:
Originally posted by visakh16


SELECT Language 
FROM
(
SELECT STUFF((select ','+lang  from M_LANG l inner join  sel_lang s on l.LID=s.lcode  where mcode in('000001') for xml path('')),1,1,'') AS Language
)t


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



A little fixing up
Go to Top of Page

svibuk
Yak Posting Veteran

62 Posts

Posted - 02/03/2013 :  00:58:29  Show Profile  Reply with Quote
THANKS



quote:
Originally posted by James K

quote:
Originally posted by visakh16


SELECT Language 
FROM
(
SELECT STUFF((select ','+lang  from M_LANG l inner join  sel_lang s on l.LID=s.lcode  where mcode in('000001') for xml path('')),1,1,'') AS Language
)t


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



A little fixing up

Go to Top of Page
  Previous Topic Topic Next 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.24 seconds. Powered By: Snitz Forums 2000