glock 71629 (1/12/2011)
This is exactly the situation where I use PowerShell frequently. I am able to export data from whatever complex query. Idea is something like this:
Invoke-Sqlcmd -ServerInstance myServer -Database MyDb -Query "SELECT * FROM SomeTable" | Export-Csv ./result.csv -NoTypeInformation
In -Query can be any T-SQL code and results are exported natively to CSV file. I work as ConfigMgr admin and this is the way how you can really easily receive your data.
David
David,
I agree that there are several ways (BCP, PowerShell, etc.) to export the results of a query to a csv file. However, this article is about building a column of comma-separated values as part of a result set... which is completely different.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes