How to insert data in multiple tables at same time
USE YourDB GO INSERT INTO MyTable (FirstColSecondCol) SELECT First 1 UNION ALL SELECT Second 2 UNION ALL SELECT Third 3 UNION ALL SELECT Fourth 4 UNION ALL SELECT Fifth 5 GO
How to delete duplicate values in a table
Following code is useful to delete duplicate records. The table must have identity column which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1 DuplicateColumn2 and DuplicateColumn3.
DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX(ID) FROM MyTable GROUP BY DuplicateColumn1DuplicateColumn2DuplicateColumn2)