January 25, 2013 at 7:52 am
So I have a query running already that executes a sqlcmd command to export the results of a query to a csv. Seems to only come out as tab delimited rather than comma delimited. How do I switch this to comma delimited?
January 25, 2013 at 8:17 am
Can you give an example of what you are running? I usually use the bcp command and use the option -t,
check out the 2 links below:
January 25, 2013 at 8:30 am
Here's the sqlcmd command, produces tab delimited data rather than comma.
declare @sql varchar(8000)
set @sql= 'SQLCMD.EXE -d SynDocsDB -i D:\MSSQL\SSIS\export.sql -o \\csg-cold01\cold\ABD\export'+ @datesql+ '.csv -s"," -W '
print @sql
exec xp_cmdshell @sql
January 25, 2013 at 11:32 am
This is interesting, when I run something very similar to this I get a comma delimated file. Are you sure that you are looking at the file in the correct location? Are there any errors when executing the cmd shell?
January 25, 2013 at 11:34 am
No errors.
Output is like this:
Something<tab>something<tab>something
Not:
something,something,something
January 25, 2013 at 12:04 pm
Try not puting the quotes around the comma just use -s,
If that still doesn't work try -s"|"
and let me know the results.
January 25, 2013 at 12:09 pm
That worked.
Sent results to the parties who requested it, let's hope they like it. 🙂
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply