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 2008 Forums
 Transact-SQL (2008)
 all rown from one table in a Varchar(max)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Clages1
Yak Posting Veteran

69 Posts

Posted - 05/03/2013 :  13:04:12  Show Profile  Reply with Quote
Hi, i am trying to get all rows from one table into a Varchar(max)

my table has one column varchar(800)
sample

aaaaaaaaaaa
bbbbbbbbbbb
cccc
dddddddd
eeeeeeeeee
etc

declare @x varchar(max)

i would like to get this

@x= aaaaaaaaaaabbbbbbbbbbbccccddddddddeeeeeeeeee

I know how to do using cursor..
is there anote option without a cursor?

tks

Carlos Lages
Dec


James K
Flowing Fount of Yak Knowledge

3761 Posts

Posted - 05/03/2013 :  13:33:09  Show Profile  Reply with Quote
SELECT colname AS [text()] FROM YourTable FOR XML PATH('');
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.05 seconds. Powered By: Snitz Forums 2000