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

Column Pivot using COALESCE command:

I read this in an article today and thought worth sharing with you.

DECLARE @val VARCHAR(1000)

SELECT @val COALESCE(@val,'') + col1 ';' 
FROM table1

SELECT @val

The above command would concatinate the output of the column col1 in table1(say 100 rows) into a single column value. We can avoid using cursors.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Thursday, July 03, 2008 2:32 PM