Tuesday, April 20, 2010

Rows to single column in Sql

Sample table as Cities in rows is convert to single column

declare @retstr varchar(8000)  
 select Top 5 @retstr =  COALESCE(@retstr + ';','') + City   
from State  
print @retstr  

No comments:

Post a Comment

Update the author and email address of every commit on a repository

source: stackoverflow.com