Is it possible to create a CSV file from a stored procedure?
I need to create a CSV file with data from a table, that is retrieved in a stored procedure
I got this to work on a simple Stored Procedure, replace "YourDatabase.dbo.YourSproc"
DECLARE @string AS NVARCHAR(4000)
SELECT @string = 'BCP "exec YourDatabase.dbo.YourSproc" QUERYOUT c:\data.csv -c -T -t'
exec master.dbo.xp_cmdshell @string