To Grasshopper......
I had a trailing backslash in the file path so I added the code below:
/* Remove the last character if it is a "back slash"
the trailing "back slash" will be concatenated later*/
IF RIGHT(@DestinationLocation,1) = '\'
BEGIN
SET @DestinationLocation = LEFT(@DestinationLocation,(LEN(@DestinationLocation)-1))
END
/* I added the code above just before the section below*/
/*------------------------------------------------------------
Stage 1: Create temp table for export data.
-------------------------------------------------------------*/
/* I added the code above just before the section above*/
I also had to add
"-S WIN7X64_2008RG\MSSQLSERVER1"
to get it to actually create the file.
I also had to specify @TextQualifier = '"'
( thats ' " ' ) a single quote, a double quote, a single quote
to actually get data in the file.
--Example of the Server added to the command string...
SET @Cmd = 'bcp "SELECT ' + @FileFields + ' FROM ##' + @SourceObjectName
+ ' ORDER BY [Order]" queryout "' + @DestinationLocation + '\' + @FileName
+ '" -S WIN7X64_2008RG\MSSQLSERVER1 -T -c -t,'
Replace "WIN7X64_2008RG\MSSQLSERVER1" with your "instance\sql server name".