Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to copy image from one row to another...

Author  Topic 

vijaykumarjoshi
Starting Member

2 Posts

Posted - 2007-09-25 : 06:02:34
Hi,

In my table I have one column of type Image. I want to copy image from one row to another.

I'm using WRITETEXT and READTEXT. Following is the code for it but it's not working..pls help me out...

DECLARE @srcPtrVal binary(16)
SELECT @srcPtrVal = TEXTPTR(COL_Image) FROM Table1 WHERE id = 3

DECLARE @DestPtrVal binary(16)
SELECT @DestPtrVal = TEXTPTR(COL_Image) FROM Table1 WHERE id = 6

WRITETEXT Table1.COL_Image @DestPtrVal (READTEXT SMP_Catalogue_Item.SMP_CI_Image @srcPtrVal 100)

Vijay

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-25 : 06:05:23
I suppose normal

UPDATE t1
SET t1.Col_Image = (SELECT t6.Col_Image FROM Table1 AS t6 WHERE t6.ID = 6)
FROM Table1 AS t1
WHERE t1.ID = 3

doesn't work for you?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

vijaykumarjoshi
Starting Member

2 Posts

Posted - 2007-09-25 : 10:16:19
No. Normal update doesn't work for text, ntext and image data types.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-25 : 10:29:36
Very strange. Are you really sure?
CREATE TABLE	#Temp
(
ID INT,
Data IMAGE
)

select * from #temp

INSERT #Temp
SELECT 1, 0x1234 UNION ALL
SELECT 6, 0x2244

select * from #temp

UPDATE t1
SET t1.Data = (SELECT t2.Data FROM #Temp AS t2 WHERE t2.ID = 6)
FROM #Temp AS t1
WHERE t1.ID = 1

select * from #temp

drop table #temp



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -