• 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


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2