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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 750
1 OriginalGriff 543
2 Abhinav S 318
3 thatraja 245
4 Tadit Dash 140
0 Sergey Alexandrovich Kryukov 8,322
1 OriginalGriff 4,790
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


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