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

Arthur Fuller artful at rogers.com
Tue May 17 12:49:58 CDT 2005


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




More information about the dba-SQLServer mailing list