Hi I'm trying to print a sql table to a file in tab delimited format.
Right now I am using the powershell line
Invoke-SQLCmd -ServerInstance $Server -Database $Database -query "select distinct * from WHIProducts" | Export-Csv -path "$inventorypath\inventory_$date\$filename" -NoTypeInformation -Delimiter "`t"
The problem I am running into is a system.outofmemoryexception.
Does anyone know of a way to do this directly through a sql query so that way I can just run the query through powershell? Or is there a more efficient way using powershell or another scripting language? This is has to be done automatically so going to SSMS and print the results to text file isn't enough.
I am using SQL Server express.