Sample table as Cities in rows is convert to single column
- State (Tablename)
- -----
- City (Columnname)
- -----
- Chennai
- Madurai
- Coimbatore
- declare @retstr varchar(8000)
- select Top 5 @retstr = COALESCE(@retstr + ';','') + City
- from State
- print @retstr
- Chennai;Madurai;Coimbatore
No comments:
Post a Comment