This is a discussion on removing data within the SQL Server forums, part of the Microsoft SQL Server category; --> I have a table that I need to delete some data from and put the deleted data into a ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have a table that I need to delete some data from and put the deleted data into a different table. How do I script the following. If Field1 in Table1 is null, remove that row from Table1 and put it in a new table called Table2 Regards, Ciarán |
| |||
| chudson...@hotmail.com wrote: > Madhivanan wrote: > > Create a newTable having the structure of Oldtable and write a query > > What is the quickest way to create a newtable with the structure of the > Oldtable? The Oldtable has over 50 fields, of many different types. Look in BOL under "generating scripts" Edward -- The reading group's reading group: http://www.bookgroup.org.uk |
| |||
| The most performant (as it hardly touches the transaction log) and easiest way to copy the data into a new table is to use the SELECT INTO command. Loom in Books Online for more detailed information on this command and why it is best for this kind of operation. This will dynamically create a new table for you with all of the required columns and their basic attributes. You can then delete the copied records from the source table. Regards, Malcolm www.dbghost.com |