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 2000 Forums
 Transact-SQL (2000)
 Move IMAGE Data

Author  Topic 

wombel
Starting Member

14 Posts

Posted - 2002-07-22 : 11:31:18
Hi,

I need to move image date (datatype image) from one table to another in a stored procedure, but it just won't work.

Can anyone help me with that?

TIA



Thomas Wrobel
Senior IT Manager

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-22 : 14:18:52
How about you post what you are trying and the error message you are getting....

This works for me....

create table imagetest (img image)
create table imagetest2 (img image)

insert into imagetest values ('blah')

insert imagetest2(img)
select img from imagetest


<O>
Go to Top of Page

wombel
Starting Member

14 Posts

Posted - 2002-07-23 : 04:49:34
Well, I guess I should have been more precise ;-)

I tried to update a table with an image field with one from another table.

I uses the following statements:

update blobtest set pic =
select pic from member_galerie_pics
where id = 42

But all I got was:
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'select'.


quote:

How about you post what you are trying and the error message you are getting....

This works for me....

create table imagetest (img image)
create table imagetest2 (img image)

insert into imagetest values ('blah')

insert imagetest2(img)
select img from imagetest


<O>

 
 


Thomas Wrobel
Senior IT Manager
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2002-07-23 : 05:01:09
ummm yeah.... The syntax is invalid.....

try something like this....

update blobtest set pic =
(select pic from member_galerie_pics
where id = 42)
where id = 42



Peace

Rick

Go to Top of Page

wombel
Starting Member

14 Posts

Posted - 2002-07-23 : 05:08:07
I tried that, too.

I used:
update blobtest set pic =
(select pic from member_galerie_pics
where id = 42)
where id = 1

But in return I got this:
Server: Msg 279, Level 16, State 3, Line 1
The text, ntext, and image data types are invalid in this subquery or aggregate expression.

Thomas Wrobel
Senior IT Manager
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-23 : 08:09:03
UPDATE b SET pic = m.pic
FROM blobtest B INNER JOIN member_galerie_pics M
ON B.id=M.id
WHERE B.id = 42


Haven't tested it but it should work. If not, you'll have to look at cursors (eeeeeeeeeeeeeeewwwwwwwwwwwwwwwww) in conjunction with READTEXT and UPDATETEXT.

Go to Top of Page

wombel
Starting Member

14 Posts

Posted - 2002-07-23 : 08:48:27
Thanks!!!
quote:

UPDATE b SET pic = m.pic
FROM blobtest B INNER JOIN member_galerie_pics M
ON B.id=M.id
WHERE B.id = 42


Haven't tested it but it should work. If not, you'll have to look at cursors (eeeeeeeeeeeeeeewwwwwwwwwwwwwwwww) in conjunction with READTEXT and UPDATETEXT.





Thomas Wrobel
Senior IT Manager
Go to Top of Page
   

- Advertisement -