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)
 insert into one table from another

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-01-09 : 14:15:10
How can I insert from one table into another --

The following is my code that returned errors.


insert into order_info(total_price,discount,notes)
values (select total_price,discount,notes
from order_info where order_id=27)


Basically what I need to do is take the order based on order it and reinsert it so it is the last order and return the identity.

Hippi
Yak Posting Veteran

63 Posts

Posted - 2005-01-09 : 14:51:40
quote:
Originally posted by esthera

How can I insert from one table into another --

The following is my code that returned errors.


insert into order_info(total_price,discount,notes)
values (select total_price,discount,notes
from order_info where order_id=27)


Basically what I need to do is take the order based on order it and reinsert it so it is the last order and return the identity.


I have no idea what u r talking about, if u just need the information of order_id=27, delete the others.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-01-09 : 14:58:23
You need to remove the VALUES keyword

insert into order_info
(
total_price,
discount,notes
)
select
total_price,
discount,notes
from
order_info
where
order_id=27



quote:
Originally posted by esthera

How can I insert from one table into another --

The following is my code that returned errors.


insert into order_info(total_price,discount,notes)
values (select total_price,discount,notes
from order_info where order_id=27)


Basically what I need to do is take the order based on order it and reinsert it so it is the last order and return the identity.



Go to Top of Page
   

- Advertisement -