Ok. Everything works, ALMOST perfectly. For some reason, I am getting 1 blank character string at the beginning of each line in my text file. It is either a blank character string or a carriage return/line feed. Here is my code:
Set @str = 'osql -Q"' + @SQL1 + '" -h-1 -E -w1000 -o' + @MySchedFile
exec master..xp_cmdshell @str
I checked the SQL and it looks fine...The output to the text file is something like this:
1,2,,1031,VT,20011210,09:00,20011210,13:00,0,20020107202043
1,2,,1031,VT,20011210,09:00,20011210,13:00,0,20020107202043
1,2,,1031,VT,20011210,09:00,20011210,13:00,0,20020107202043
1,2,,1031,VT,20011210,09:00,20011210,13:00,0,20020107202043
1,2,,1031,VT,20011210,09:00,20011210,13:00,0,20020107202043
but there is always an extra space before the 1st 1 of each line...