Baskar B.V

SQL - BI Consultant

  Home  |   Contact  |   Syndication    |   Login
  23 Posts | 0 Stories | 21 Comments | 0 Trackbacks

News

Baskar

Archives

Blogs

SQL-BACKUPS

SQL-PERFORMANCE

SQL-SERVER

Tuesday, January 26, 2010 #

 

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)