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 2008 Forums
 Transact-SQL (2008)
 Insert PDF into Sql Svr 2008 varbinary(max)

Author  Topic 

McGurk
Starting Member

21 Posts

Posted - 2010-02-03 : 10:44:31
I need to store a PDF in my existing db table record. What statement can I use to do this?

McGurk
All that is gold does not glitter, not all those who wander are lost... JRR Tolkien

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-02-03 : 11:12:27
INSERT statement. It's up to your application to read and write the binary values for it. This article should help: http://msdn.microsoft.com/en-us/library/a1904w6t(VS.80).aspx
Go to Top of Page

McGurk
Starting Member

21 Posts

Posted - 2010-02-03 : 14:30:26
Thanks for the reply. Not always, in this case, I need to enter it into the db using tsql.

McGurk
All that is gold does not glitter, not all those who wander are lost... JRR Tolkien
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-02-03 : 14:53:27
yes, you still use T-SQL INSERT statement. What I mean is that the app needs to decipher it and put it back as a pdf when you read it out
Go to Top of Page

McGurk
Starting Member

21 Posts

Posted - 2010-02-03 : 17:39:42
Sorry, I misunderstood. Yes, the app does do that.

For anyone looking for a similar solution, below is the TSQL statement:

USE MyDBName;
GO
UPDATE MyTableName
SET MyColumnName = (
SELECT *
FROM OPENROWSET(BULK 'C:\MyFile\MyImage.pdf', SINGLE_BLOB) AS MyColumnName)
WHERE PrimaryKeyId = 1002;

McGurk
All that is gold does not glitter, not all those who wander are lost... JRR Tolkien
Go to Top of Page
   

- Advertisement -