How to insert image in a table??

  • Hi!

    I have a table that has two fields name and photo(image type) I want to insert a record in this table that consists of name and the snap of the person, how can I insert the image in the table from a file on the disk.

    create table (

    name varchar(20),

    photo image

    )


    Best Regards,

    Indu Jakhar

  • You can use textcopy utility from SQL server.

    Find out syntax Textcopy /?

    One can find the utility in mssql\binn folder.

  • Hi wz700!

    I want to give my user an option to upload a picture and store it in SQL 7.0 database, how can I acheive that, I tried to get the syntax of textcopy command but its not there in the online books for SQL 7.0.


    Best Regards,

    Indu Jakhar

  • why you don't try to store the path of the Image only in your database ... (less store , fast response)

    and backup the folder that holds this image frequently


    Alamir Mohamed
    Alamir_mohamed@yahoo.com

  • I m agreed , If he stores the path of the image  in the data base it would be fast but it will problametic if any one remove that image from that partcular path.

    but, by this way of storing image in the table , that images will be safe.

     

     

     

    - Manish

  • You cannot "upload" directly using SQL Server.  You will have to create a front end tool (GUI) of some kind for the user.  You can do it in Access, ASP, or ASP.net (just to name a few).

    You should check the .Net forums for methods of doing the upload and storage of the image. 

    Your table design will need to be different.  You will need at least 3 more columns if I remember correctly.

    FileType  Varchar(3)  (jpg, gif, etc)

    ImageHeight  int

    ImageWidth  int

    If you use Access as a front end tool, you will not need these columns, but if you want to display them with anything other than Access, you will need them.

  • I would agree with the others above. 

    In general BLOBS are a bad idea. 

    SQL is not the best platform for File storage. 

    If you are concerned about security of the images encrypt them before you store them.  We do just that for all types of digital media utilizing .net encryption then we just save the Guid (our item name) of the file.  works very well.

     

    hope that helps

     

    Tal McMahon


    Kindest Regards,

    Tal Mcmahon

  • This is no black or white topic, but rather an 'it depends', IMHO.

    You might want to have a look at this one

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply