在openrowset中使用变量 [英] using variables in openrowset
本文介绍了在openrowset中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
INSERT INTO tblSmartpayFiles
(intFKACBFileID,strFileType,strPACSNum, binFileContent)
SELECT (select intPKAutoACBFileID from tblACBFiles where strPacsNum = @pacs),@type, @pacs,
BulkColumn FROM OPENROWSET(
Bulk 'd:\FilestreamData\L1DAYESHM6', SINGLE_BLOB) AS BLOB
嗨我有上面用来测试的脚本,但现在我需要更换目录后Bulk到一个名为@directory的变量。
我将如何进行此操作?
只是添加@directory无效。< br $>
Hi I have the above script which i used to test with,but now i need to replace the directory after the "Bulk" to a variable named @directory.
how will I go about doing this?
just adding @directory doesnt work.
Bulk @directory, SINGLE_BLOB) AS BLOB
所以最终我想要这样的东西。
so ultimately i want something like this.
推荐答案
你可以使用动态查询来完成它,比如
声明sql1 varchar(2000)
sql1 =''INSERT INTO tblSm
artpayFiles(intFKACBFileID,strFileType,strPACSNum,binFileContent)SELECT(select intPKAutoACBFileID来自tblACBFiles,其中strPacsNum =''+ @pacs +
''),''+ @ type +'',''+ @pacs +'',BulkColumn FROM OPENROWSET(Bulk''+ @目录+'',SINGLE_BLOB)AS BLOB''
这可以帮助你试试这个和通用电器还有任何进一步的问题。
You can do it using dynamic query like
Declare sql1 varchar(2000)
sql1 = ''INSERT INTO tblSm
artpayFiles (intFKACBFileID,strFileType,strPACSNum, binFileContent) SELECT (select intPKAutoACBFileID from tblACBFiles where strPacsNum ='' + @pacs +
''),'' + @type + '','' + @pacs + '', BulkColumn FROM OPENROWSET( Bulk'' + @directory + '', SINGLE_BLOB) AS BLOB''
This may helps you try this and getback it there are any further issues.
这篇关于在openrowset中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文