SQL Server data import after modifying tables
-
22-03-2021 - |
Question
I have a database backup which I imported into SQL Server and made few changes by adding some columns. Did not remove any of the existing columns but added some extra.
Now I wish to import the same database once again so I have all the latest data which was being entered in old one while I was working on adding columns.
What would be the proper, effective and efficient way to achieve this?
Thanks for suggestions.
Solution
Restore the Backup on the same server, then run this:
INSERT INTO Production.dbo.table1 ( column1, column2, integercol, stringCol )
SELECT column1, column2, 16, 'add text value'
FROM Backup.dbo.table1
You can add a where clause and specific columns accordingly.
The column count on the select has to match the insert.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow