I need to loop through a table and for each row extract a pdf of an invoice from each row.
I have found the command below which extracts an image.
Code:
declare @bcpCommand varchar(1000);
SET @bcpCommand = 'bcp "SELECT Invd_PDF_Image FROM Invoice_Details WHERE inv_ref = ''17992'' " queryout "C:\17992.pdf" -T -n';
SELECT @bcpCommand;
EXEC master..xp_cmdshell @bcpCommand;
I have put a loop round it using an SQL cursor for each table row.
However I don't know how to capture the 'output' results to check if the extract was a success for each row.
Ideally I want to log each extract to a table with datetime, invoice number and error details.
The output is displayed in the Sql Server Management Studio Query results window as :-
Code:
Starting copy...
NULL
1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 31 Average : (32.26 rows per sec.)
NULL
When it is not successful is shows:-
Code:
NULL
Starting copy...
NULL
0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 15
NULL
Can somebody point me in the right direction?
Dazed and confused.
Remember.. 'Depression is just anger without enthusiasum'.