How do I upload a file to a varbinary(max) column in SQL Server 2008, using TSQL?

前端 未结 1 1467
后悔当初
后悔当初 2021-01-04 00:28

This must be possible because I believe I\'ve done it before. Here\'s my query:

insert into exampleFiles Values(NEWID(), cast(\'c:\\filename.zip\' as varbina         


        
相关标签:
1条回答
  • 2021-01-04 01:25

    Does this help?

    USE AdventureWorks
    GO
    CREATE TABLE myTable(FileName nvarchar(60),
      FileType nvarchar(60), Document varbinary(max))
    GO
    
    INSERT INTO myTable(FileName, FileType, field_varbinary)
       SELECT 'Text1.txt' AS FileName,
          '.txt' AS FileType,
          * FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document
    GO
    

    Taken from here: http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/513cbf8c-21a8-4bcc-a565-6eb06437a398

    0 讨论(0)
提交回复
热议问题