Bcp query out is new to me I believe I have the correct syntax but the export is only that of a blank file what am I doing incorrectly. The files must all be only one line of data, the files are created but again with no data exported.
DECLARE moldline CURSOR LOCAL STATIC FOR
select wo,Line from EspiMoldExport
WHILE 1 = 1
FETCH NEXT FROM moldline INTO @conum,@coline
if @@FETCH_STATUS <> 0
SET @filename = 'Mold_' + rtrim(ltrim(@conum)) + '_' + rtrim(ltrim(CAST(@coline AS VARCHAR(2)))) +'.csv'
SET @FILENAME = isnull(@FILENAME, 'MISS')
SET @elog = 'bcp "select * from SyteLine_POLY_App.dbo.EspiMoldExport where WO =''@conum'' and Line = ''@coline'' " queryout \\fp01\companyfiles\moldLogs\' + @filename + ' -c -t, -T -SESPIDATA'---elogload.csv
exec master..xp_cmdshell @elog
select * from SyteLine_POLY_App.dbo.EspiMoldExport where wo = @conum and line = @coline