Pages

Search This Blog

Wednesday, October 13, 2010

[T-SQL] How to generate CSV from Table Data

Here is a very simple code:

DECLARE @Str VARCHAR(MAX)
SELECT @Str = COALESCE(@Str+',' , '') + FieldName
FROM TableName
SELECT @Str

*Field Name should be replaced with Field Name
*Table Name should be replaced with Table Name

No comments: