Geeks With Blogs
Baskar B.V SQL - BI Consultant

 

Below code is to retrieve column of values into one variable without using cursors.

declare

@col_list varchar(max)

set

@col_list = ''

select

@col_list = @col_list + col1 + ', '

from

(select column1 as col1 from table1 ) d order by col1

select

@col_list = left(@col_list, len(@col_list)-2)

 

Posted on Tuesday, January 26, 2010 11:28 PM | Back to top


Comments on this post: Code to retrieve column of values into one variable as comma separate

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Baskar B.V | Powered by: GeeksWithBlogs.net