[dba-SQLServer] Insert a picture into a SQL column

James Barash James at fcidms.com
Tue May 17 15:27:55 CDT 2005


Arthur:

I think this article will give you what you are looking for. It's not very
straightforward but if you are determined to do this in T-SQL, it does work.

http://www.databasejournal.com/features/mssql/article.php/1443521

Just remember that filenames must be from the Server's point-of-view.

Hope this helps.

James Barash


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Fuller
Sent: Tuesday, May 17, 2005 1:50 PM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] Insert a picture into a SQL column


That was interesting but not exactly where I want to go. If at all 
possible, I want to do it all in the SQL database, using a sproc that 
might resemble this:

CREATE PROCEDURE ImageImport_ap
(
    @pk int,
    @imageFileName varchar(100)
)
AS
    /* maybe I need a stream object or something here, I don't know
       but I want ideally to handle everything in the sproc, with no FE 
code but passing the parms
    */
    UPDATE myTable
    SET Picture = [data read from image file]
    WHERE PK = @pk

Anyone know how to achieve this?
Arthur

Francisco Tapia wrote:

>Look in BOL under blob,
>here is a MS example on how to do what you want
>
>http://support.microsoft.com/kb/q173308/
>
>I'm looking at a similar situation only because I'm going to need to 
>display
>the same picture out on the web as in an internal app. Not sure if I'll
use 
>this approach due to the typical cautions.
>
>On 5/16/05, Arthur Fuller <artful at rogers.com> wrote:
>  
>
>>Let's leave aside the wisdom of doing this and focus on the fact of 
>>doing it. I have a sproc that doesn't work. I pass a filename and the 
>>PK of the row into which I want to insert said image file. It doesn't 
>>work as written. I think that maybe I need to create a stream object 
>>and read chunks and then update the row using said accumulated chunk, 
>>but I cannot yet figure out how to do this in pure T-SQL.
>>
>>Suggestions?
>>
>>TIA,
>>Arthur
>>
>>    
>>
>>>      
>>>
>>--
>>No virus found in this outgoing message.
>>Checked by AVG Anti-Virus.
>>Version: 7.0.308 / Virus Database: 266.11.10 - Release Date: 5/13/2005
>>
>>_______________________________________________
>>dba-SQLServer mailing list
>>dba-SQLServer at databaseadvisors.com
>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>>http://www.databaseadvisors.com
>>
>>
>>    
>>
>
>
>  
>


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.10 - Release Date: 5/13/2005

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com





More information about the dba-SQLServer mailing list