Ok Man try the code belowBelow is a sample that calls this UDF with chunks of 2400 characters (because of the way Base64 encoding works, the “chunk” size has to be divisible by 4).CREATE PROCEDURE testConvert @someParameter int, @attachmentData textAS/*** Table schema used for testCREATE TABLE testData(someValue int, attachmentData image, CONSTRAINT PK_testData primary key nonclustered (someValue))***/-- insert NULL (0x0) into the image field so that the TEXTPTR function will workinsert testData(someValue, attachmentData)values(@someParameter, 0x0)declare @pointer varbinary(16)select @pointer = TEXTPTR(attachmentData) from testData where someValue = @someParameterdeclare @buff varchar(2400)declare @offset int, @imgOffset intset @offset = 1set @imgOffset = 0while @offset <= datalength(@attachmentData)begin select @buff = substring(@attachmentData, @offset, 2400) declare @img varbinary(8000) select @img = dbo.base64toBin(@buff) UPDATETEXT testData.attachmentData @pointer @imgOffset NULL @img set @imgOffset = @imgOffset + datalength(@img) set @offset = @offset + 2400end
to read the full orginal article you can go tohttp://geekswithblogs.net/scarpenter/archive/2005/10/19/57442.aspxpaul Tech