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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-04-09 : 12:28:33
|
| hesham writes "hi, We have two tables with the same structure some users insert data in the first table and the others insert the same data into the another table the all users can duplicate insert the data again by mistak .. there is no uniqe index , no foreign key ,no primary key ..So I want to delete the identically rows which inserted into two tables and display the records which inserted in one table and didn't insert in the another as this example :table A , table B1 , 11 , 12 , 1 2 , 22 , 23 , 45 , 67 , 5and the result will be :table A , table B2 , 13 , 47 , 6thanks." |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-04-09 : 14:33:53
|
| 1. Insert the identical rows into a temp table.2. Delete the rows from both tables that are left.3. Do a select using a FULL OUTER JOIN. (This will be nasty.)4. Create a table that just has an identity column.--Use this to drive the insert for now on so you don't have to worry about this.5. Put a primary key on these tables.6. Put a foreign key on the tables from the new table you make to produce this. (It would be better if you could just combine the tables and put a type on there or something.)***Before you do any of the above, could you explain what the tables are for? Why are they two different tables? What is their function?MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|
|
|