SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to copy image from one row to another...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vijaykumarjoshi
Starting Member

2 Posts

Posted - 09/25/2007 :  06:02:34  Show Profile  Reply with Quote
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

Sweden
30111 Posts

Posted - 09/25/2007 :  06:05:23  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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 - 09/25/2007 :  10:16:19  Show Profile  Reply with Quote
No. Normal update doesn't work for text, ntext and image data types.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30111 Posts

Posted - 09/25/2007 :  10:29:36  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000