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)
 Concatenate multiple rows
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

FacE3ater
Starting Member

2 Posts

Posted - 01/31/2013 :  16:18:11  Show Profile  Reply with Quote
Hey guys, I am trying to gather all the text from a Description field on multiple liens, and insert it into one. It hits the first line, then doesn't find the rest. I know for this criteria, there are 4 lines with different descriptions. Here is my code:

update ps_doc_note
NOTE_TXT = cast(ps_doc_lin.DESCR as varchar)+ cast(NOTE_TXT as varchar), NOTE = cast(ps_doc_lin.DESCR as varchar)+ cast(NOTE_TXT as varchar)
from PS_DOC_LIN
full join ps_doc_note
on PS_DOC_LIN.DOC_ID = PS_DOC_NOTE.DOC_ID
where item_no = '13' and ps_doc_lin.DOC_ID = 108109492327


Thanks,

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/01/2013 :  02:46:06  Show Profile  Reply with Quote

update ps_doc_note
NOTE_TXT = STUFF((SELECT ' ' + DESCR FROM PS_DOC_LIN WHERE DOC_ID = ps_doc_note.DOC_ID FOR XML PATH('')),1,1,'')
FROM ps_doc_note 


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

Go to Top of Page

FacE3ater
Starting Member

2 Posts

Posted - 02/01/2013 :  09:01:44  Show Profile  Reply with Quote
Worked! Awesome thanks!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/01/2013 :  12:40:08  Show Profile  Reply with Quote
welcome

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

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.02 seconds. Powered By: Snitz Forums 2000