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
 General SQL Server Forums
 New to SQL Server Programming
 inserting binary values from table to another

Author  Topic 

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-17 : 10:07:18
hiii,
i would like to know how to insert an image field from one table to another in sql 2000 ex

insert into fax_doc1(docno,dms_docdata) values (select docno, dms_docdata from fax_doc2 where dms_docno='631')

where docdata columns are binary datatypes

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-17 : 11:19:57
[code]insert into fax_doc1(docno,dms_docdata)
select docno, dms_docdata from fax_doc2 where dms_docno='631'[/code]
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-18 : 00:27:31
Thankssssssssssss u r z saving angel :D
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 00:55:49
Cheers
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-18 : 09:11:28
ok this how to insert but the update fails y !!!


update fax_doc set
dms_docdata = (select dms_docdata from fax_doc where dms_docno='631')
where dms_docno='686'

The text, ntext, and image data types are invalid in this subquery or aggregate expression.
how to fix thanks again
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 09:14:05
whats the datatype of dms_docdata?
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-18 : 09:34:55
image same i inserted to the image but now i want to update the replace the content with another already inserted record
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 10:40:12
use UPDATETEXT function found below

http://www.sqlservercentral.com/articles/Miscellaneous/handlingthetextdatatype/985/
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-19 : 03:38:07
sorry may be i was not clear in the previous comment but what i have to do is to replace the whole image field with a new image field already exist in another column i.e. not to modify the content of the field
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-19 : 03:45:00
quote:
Originally posted by ann06

sorry may be i was not clear in the previous comment but what i have to do is to replace the whole image field with a new image field already exist in another column i.e. not to modify the content of the field


i know that. but you need to get start pointer of text using TEXTPTR and then use UPDATETEXT as explained in article
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-19 : 03:52:43
Try this
update		fd
set fd.dms_docdata = w.dms_docdata
FROM fax_doc AS fd
inner join fax_doc AS w on w.dms_docno = '631'
where fd.dms_docno = '686'



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-19 : 05:40:08
ewwww it worked :D
thanks guys mr. Visakh and mr. Peso
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-19 : 06:04:21
I hope you get that UPDATETEXT out of your head...



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-19 : 09:06:41
saved it for another kind of crisis :D
Go to Top of Page
   

- Advertisement -