Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
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.
 
 Bulk @directory, SINGLE_BLOB) AS BLOB
 
so ultimately i want something like this.
Posted 5-Dec-12 1:45am
Edited 5-Dec-12 2:07am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Member 9374423 at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 6 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100