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.
| Author |
Topic |
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2011-11-15 : 00:09:05
|
| Hi there,Here is the scenario:tableA has columns of SalesID, SalesDate, CustomerNametableB has columns of CustomerID, CustomerNameNow I need to insert tableA to tableC with columns as:SalesID, SalesDate, CustomerIDHow should I do this? Thanks in advance. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-15 : 00:20:32
|
| [code]insert into tableCselect a.SalesID, a.SalesDate,b.CustomerIDfrom tableA ainner join tableB bON b.CustomerName = a.CustomerName[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-15 : 04:48:11
|
| Why do you need a seperate table for this as you can show it in SELECT statement or create a view based on it?MadhivananFailing to plan is Planning to fail |
 |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2011-11-15 : 12:33:02
|
| Thanks visakh16, it works. |
 |
|
|
|
|
|