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 2005 Forums
 Transact-SQL (2005)
 Create a new table

Author  Topic 

agarwasa2008
Posting Yak Master

109 Posts

Posted - 2009-10-06 : 18:54:47
There are 2 tables as shown below. The Prd id is same as the Order id. But there are some Prd names that do not exists and some type that do not exists. Need to create a new table and insert all the values in that. For Example:

32145 Chairs furniture
32410 Tables Null
12345 null misc

Prd table
Prd id, 32145 32410
Prd Name chairs tables

Order table
Order id, 32145 12345
Prd type furniture misc


SA

sanoj_av
Posting Yak Master

118 Posts

Posted - 2009-10-06 : 23:52:32
[quote
there are some Prd names that do not exists and some type that do not exists.
[/quote]


Do no exist where?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-07 : 00:23:53
[code]
insert into new_table(id, prd_name, prd_type)
select p.prd_id, p.prd_name, o.prd_type
from prd p inner join order o on p.prd_id = o.order_id
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -