How can I insert & update image

  • Dear All,

    How can i insert, and update image to SQL Server Table which consist a column with image data type.

    kind regards

     

     


    shifan

  • Hi,

    You can use BII from SQL RKits 2000 , textcopy utility, or  a simple application built in .Net.

  • If you're doing this thru an application (VB, ASP, etc) you can also use stored procedures that pass image parameters called via ADO, ADO.NET, etc.

  • is it system supplied SP? can you send the SP?

    regards

     

     


    shifan

  • Here is the table structure I use:

    FileID uniqueidentifier

    FileNM varchar(255) -- just the filename, not the path info

    SizeDM bigint

    ContentTypeID varchar(100) -- MIME type

    UploadDT smalldatetime

    ContentBD image -- binary data content

    ExtensionCD varchar -- a computed column set to ([dbo].[fnFileExtension]([FileNM]))

    -- Extracts an extension from a filename.

    CREATE FUNCTION dbo.fnFileExtension ( @FileNM varchar(255) )

    RETURNS varchar(10)

    AS

    BEGIN

    DECLARE @DotPos int, @Ext varchar(10)

    SET @FileNM = REVERSE(@FileNM)

    SET @DotPos = CHARINDEX('.', @FileNM)

    IF @DotPos = 0

    SET @Ext = ''

    ELSE BEGIN

    SET @Ext = SUBSTRING(@FileNM, 1, @DotPos - 1)

    SET @Ext = REVERSE(@Ext)

    END

    RETURN @Ext

    END

    This is the SP which adds a new file:

    CREATE PROCEDURE dbo.procFile_ADD

    @FileNM varchar(255),

    @SizeDM bigint,

    @ContentTypeID varchar(100),

    @ContentBD image,

    @FileID uniqueidentifier OUTPUT

    AS

    SET NOCOUNT ON

    BEGIN

    SET @FileID = NEWID()

    INSERT INTO tblFile (FileID, FileNM, SizeDM, ContentTypeID, UploadDT, ContentBD)

    VALUES (@FileID, @FileNM, @SizeDM, @ContentTypeID, GETDATE(), @ContentBD)

    END

    GO

    Hope this helps. Sorry my post isn't nicely formatted. I have to use the non-WYSIWYG form on SSC.com because the fancy one never loads for me.

  • thanks a lot Milzs.


    shifan

Viewing 6 posts - 1 through 5 (of 5 total)

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