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)
 all rown from one table in a Varchar(max)
 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

3873 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  
 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