Created
September 22, 2013 21:53
-
-
Save Cyberloki/6664244 to your computer and use it in GitHub Desktop.
Create a new table dynamically and insert records (Select Into)
Copy records into existing table (Insert Into)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- create a new table and insert records | |
| -- ===================================== | |
| select * into newtablename from MyFirstTable | |
| -- copy records into existing table | |
| -- ===================================== | |
| insert into ReprocessTable(event_time, [msg]) select event_time, [msg] from FailedTable order by [id] | |
| -- create a new table with records from another database | |
| -- ===================================== | |
| use MyDB | |
| GO | |
| select * into newtablename from MyOtherDB..MyFirstTable | |
| GO | |
| -- copy records from another database into existing table | |
| -- ===================================== | |
| use MyDB | |
| GO | |
| insert into MyTable(event_time, [msg]) select t.event_time, t.[msg] from MyOtherDB..TheirTable t order by t.[id] | |
| GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment