Using SQL Server 2000
Master Table
ID Date Value
001 23-04-2009 200
001 24-04-2009 300
002 23-04-2009 250
002 24-04-2009 350
002 25-04-2009 250
....
Secondary Table
ID Date Value
001 23-04-2009 200
001 24-04-2009 300
002 23-04-2009 250
002 24-04-2009 350
002 25-04-2009 250
002 26-04-2009 550
....
In the master table i want to insert a data’s from the secondary table (Each data’s should insert from next date onwards for each id)
If i am inserting secondary table data’s in to master table, master table should accept id from next date onwards…
Expected output
ID Date Value
001 23-04-2009 200 'old record from master table
001 24-04-2009 300 'old record from master table
002 23-04-2009 250 'old record from master table
002 24-04-2009 350 'old record from master table
002 25-04-2009 250 'old record from master table
002 26-04-2009 550 'New Record from Secondary Table
Below mentioned record is not inserted in the master table, because date is available for the id’s in the master table
001 23-04-2009 200
001 24-04-2009 300
002 23-04-2009 250
002 24-04-2009 350
002 25-04-2009 250
How to make a query for insert a record with validation(id and date).
Need SQL Query Help
this query should return the desired rows that are supposed to be inserted in main table, I have not tested the query, pardon any bugs