用于将二进制数据导出到服务器的游标 [英] Cursor For Export Binary Data to Server

查看:64
本文介绍了用于将二进制数据导出到服务器的游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个光标将二进制数据导出到特定格式到指定位置



Hi all,

I have one cursor which export the binary data into the particular format to the specified location

declare cur cursor for 
select Document.DocumentID from Reports.[Document] inner join REPORTS.ReportVersion 
    on ReportVersion.DocumentID = [Document].DocumentID
    Inner join Reports.Report on Report.ReportID = ReportVersion.ReportID AND ReportVersion.Active = 1
    Inner Join Reports.EntityReport on Report.ReportID = EntityReport.ReportID
    Inner join orders.ApCase on EntityReport.EntityID = ApCase.CaseID
     WHERE
    ApCase.CaseNo = 'ALK13-000047' and EntityReport.Active = 1
    GO
open cur
declare @id int
DECLARE  @Command NVARCHAR(4000)
fetch next from cur into @id
while (@@FETCH_STATUS = 0)
begin
    
SET @Command = 'bcp "SELECT DocumentBinary FROM Apvx_Biot.Reports.Document where DocumentID = '+ convert(varchar(30),@id) + ' " queryout "C:\Image\Test.pdf" -T -n -Sxyz -Uxyz -Pxyz'
EXEC xp_cmdshell   @Command
    fetch next from cur into @id
end
close cur
deallocate cur



现在我的要求是如何在运行时更改File的名称,因为我将获得多于1个DocumentID但我们已经硬编码了文件名,如test.pdf我想保存不同名称的文件..



问候

拉曼


Now my requirement is how I will change the name of File at runtime because I will get more than 1 DocumentID but we have hard coded the file name like test.pdf I want to save the files with different names..

Regards
Raman

推荐答案

这可能对你有所帮助 http://stackoverflow.com/questions/12204577/exporting-binary- file-data-images-from-sql-via-a-stored-procedure [ ^ ]
may this may helps you http://stackoverflow.com/questions/12204577/exporting-binary-file-data-images-from-sql-via-a-stored-procedure[^]


这篇关于用于将二进制数据导出到服务器的游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆