• Yeah, I boneheaded that one. It works now, and the file output is correct.

    So, I took it and applied it to the table I want to write as a file, and it works fine there as well. I guess it's something else in the process making it go woogy. Maybe it's when the files get combined?

    set @sql= 'exec master..xp_cmdshell ''type '+@data_file+' >> '+@filepath+@file_name+''''