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
 insert into

Author  Topic 

asm
Posting Yak Master

140 Posts

Posted - 2005-11-08 : 00:15:03
Hi

I have two table both table contains data.
Now i want to insert data from one table to another table.
Pls help how can i achive the same.

i have try this query but this will delete the all data.

select class.* into grop from class

thanks

asm

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-11-08 : 00:19:26
Try this..

Insert Grop
Select * From Class

Or

Insert Grop (Column_Name.....)
Select Column_Name ... From Class

OR

Insert Grop
Select Column_Name .. From Class

Hopee this works for you.

Complicated things can be done by simple thinking
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-08 : 00:21:58
You need to create the table before using that Insert statement

Otherwise run this

Select * into grop from class

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

asm
Posting Yak Master

140 Posts

Posted - 2005-11-08 : 01:49:17
No one query is working...

asm
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-08 : 01:51:45
What is the error you get?
Give more details

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-11-08 : 02:01:17
Are you getting the duplication errors???

If so then you can try out the following query ..

Insert Grop
Select * From Class Where UnquieKey Not In (Select UnqueKey From Grop)

???

Or specify the error in more details.

Complicated things can be done by simple thinking
Go to Top of Page

asm
Posting Yak Master

140 Posts

Posted - 2005-11-08 : 02:01:51
thanks problem has been solved...

asm


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-08 : 02:10:04
Use Exists also

Insert Grop
Select * From Class C Where not exists (Select UnqueKey From Grop where key=C.key)




Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -