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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 all rown from one table in a Varchar(max)

Author  Topic 

Clages1
Yak Posting Veteran

69 Posts

Posted - 2013-05-03 : 13:04:12
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-03 : 13:33:09
[code]SELECT colname AS [text()] FROM YourTable FOR XML PATH('');[/code]
Go to Top of Page
   

- Advertisement -