Insert Query for Image data type in table

  • What will be the insert query for this table

    CREATE TABLE [dbo].[Table1] (

     [Id] [int] NULL ,

     [Pics] [image] NULL

    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    GO

    i am little confuse in image datatype

    thanx in advance

  • For INSERT, it's pretty straightforward.

    INSERT INTO dbo.Table1 (ID, Pics)

    VALUES (1,{Image BLOB})

    You get into real problems when trying to use UPDATE, though. Generally speaking, you can't UPDATE blob fields (such as text and image). You have to use READTEXT and WRITETEXT, which are very unwieldy, especially when working with images.

    As a frequently used solution, try storing your images outside the database. Then, just store the path to the image file in the database. It's MUCH easier to work with, and much gentler on storage/backups/etc.

Viewing 2 posts - 1 through 1 (of 1 total)

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