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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select @extra = @extra + fullname from customers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

219 Posts

Posted - 05/12/2013 :  05:07:28  Show Profile  Click to see mike13's MSN Messenger address  Reply with Quote
Hi all,

For some reason this is not working
select @extra = @extra + CAST(shipdate AS nvarchar(255)) + '<br>' from orders

when i just do this it returns a records set it returns 2 records

any idea what is wrong

thanks a lot

James K
Flowing Fount of Yak Knowledge

3865 Posts

Posted - 05/12/2013 :  10:13:42  Show Profile  Reply with Quote
Seems fine to me, assuming you are declaring and initializing @extra:

declare @extra nvarchar(max);
set @extra = '';
select @extra = @extra + cast(shipdate as nvarchar(255)) + '<br>' from orders;
select @extra;
You can also try the following (which has the added benefit that it will let you order the dates if you need to so they appear in a predictable order in the final string
		(select cast(shipdate as nvarchar(255)) + '<br>' from orders for xml path('')) 
	as xml).value('.','nvarchar(max)')
Go to Top of Page

Bustaz Kool
Flowing Fount of Yak Knowledge

1827 Posts

Posted - 05/13/2013 :  13:19:49  Show Profile  Reply with Quote
How many records are you expecting?

There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber
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.08 seconds. Powered By: Snitz Forums 2000