Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
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



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.

SQL
Bulk @directory, SINGLE_BLOB) AS BLOB


so ultimately i want something like this.
Posted
Updated 5-Dec-12 2:07am
v2

1 solution

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.
 
Share this answer
 
Comments
Member 9374423 7-Dec-12 1:31am    
hi I have solved it by adding the insert into C# VIA a "INSERT INTO tblSm ....."
thank you very much for the contribution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900