Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Insert files into a varbinary column using 0x...

Author  Topic 

brace77
Starting Member

25 Posts

Posted - 2010-05-05 : 03:41:24
I'd like to insert files into a varbinary(max) field using a script.

Like

INSERT INTO MyTable VALUES
(
'MyFile.pdf', -- FileName a varchar(1000) field
0x000040F4034....0934 --DATA a varbinary(max) field
)

I have those questions:
1) how do I convert the content of a file into 0x.... ?
2) is there a limit to the 0x.... size? Can I use this approach for files of every size (like 100MB)?

NOTE1: I am not using this in this way, what I am really trying to do is a CLR stored procedure to insert the file into a server's folder.

Something like

exec sp_clr_InsertFile
@destination_file_name ='c:\Folder\MyFile.pdf'
, @file_contents=0x000040F4034....0934 -- this could be VERY LARGE

NOTE2: I need to support SQLServer 2005 and newer.

brace77
Starting Member

25 Posts

Posted - 2010-05-06 : 07:27:03
I really cannot find this information on the internet, could anyone be so kind to help me? Thanks.
Go to Top of Page
   

- Advertisement -