SQL Server / PowerShell / Exporting data from a SQL Server table to multiple comma-separated value (CSV) files using PowerShell

SQL Server / PowerShell / Exporting data from a SQL Server table to multiple comma-separated value (CSV) files using PowerShell
Export SQL Data to multiple CSV files. There are many different ways to do this (SSIS, TSQL) but I think that PowerShell could be really efficient tool for such small random tasks. For this example I will use test table with 17220 rows. First step is to export whole table to CSV file using export-csv cmdlet.  Export-CSV converts objects into a series of comma-separated value (CSV) strings and saves the strings to a file. If you want to find more details about Export-CSV cmdlet and see more usage examples you can read this MS article. param (...
read more