I have problem executing xp_cmdshell (I think). In stored procedure I need to create files using bcp. Process should work as following: text file is created in temp folder using bcp, then file is moved from temp to permanent location where it's picked up by another application.
This is supposed to be automated, continuously running process. But once in a while files do not moved (bcp created files successfully in temp folder, but then error accrue and procedure terminated). As a result I have files piled up in temp folder. I tried to trace this problem, but all I could see at the time of error is 'Severity 25' and no error description.
The weird thing about this problem is: it doesn't happened all the time, just once in a while.
This is code I'm using:
-------------------------------------------
--creates file in 'temp' folder
set @strCmd='bcp "select Line from BDName.dbo.tempToFile" queryout '+ @PathName+ 'Temp\' + @FileName + ' -c -a 30000 -S SERVERNAME '
EXEC master..xp_cmdshell @strcmd
--moves file from temp folder to 'PathName' folder
set @strCmd='move '+@PathName+'Temp\' + @FileName + ' ' + @PathName + ' '
EXEC master..xp_cmdshell @strcmd
--------------------------------------------
Could anybody please help me to resolve this problem - I'm new at this and I don't even know how to find out what the error/cause of the problem is.
Thank you very much,
Lena
This is supposed to be automated, continuously running process. But once in a while files do not moved (bcp created files successfully in temp folder, but then error accrue and procedure terminated). As a result I have files piled up in temp folder. I tried to trace this problem, but all I could see at the time of error is 'Severity 25' and no error description.
The weird thing about this problem is: it doesn't happened all the time, just once in a while.
This is code I'm using:
-------------------------------------------
--creates file in 'temp' folder
set @strCmd='bcp "select Line from BDName.dbo.tempToFile" queryout '+ @PathName+ 'Temp\' + @FileName + ' -c -a 30000 -S SERVERNAME '
EXEC master..xp_cmdshell @strcmd
--moves file from temp folder to 'PathName' folder
set @strCmd='move '+@PathName+'Temp\' + @FileName + ' ' + @PathName + ' '
EXEC master..xp_cmdshell @strcmd
--------------------------------------------
Could anybody please help me to resolve this problem - I'm new at this and I don't even know how to find out what the error/cause of the problem is.
Thank you very much,
Lena