I'm trying to create a csv using SQL Command. I am using a simple table as a test. I've written this so far:
DECLARE @sql VARCHAR(1000),
@cmd VARCHAR(100),
@sqlCommand VARCHAR(1000)
Set @cmd = 'Select * From DSG.Pawtucket.counts'
SET @sqlCommand = 'SQLCMD -S <server> -U <user> -P <password> -d <database> -W -Q "' + @cmd + '"
-s "|" -o <network path> -h-1'
EXEC master.dbo.xp_cmdshell @sqlCommand
I see the query results in the 'results' tab and I receive no errors but my file is never created. I know I am using a valid network path. I even tried just creating the file on the SQL servers local C: drive with no success. I also tried using bcp with much frustration and no results. Any help would be greatly appreciated!