Here's how you can restore an entire table or only parts of a table without restoring the entire database.
This is best used on _Ref<X> tables, tables that are only ever changed if you do it yourself. Dynamic tables like _Items or _Char are subject to problems if you use this kind of query and I don't recommend it and won't help you if you do it and something breaks.
First
ALWAYS MAKE A BACKUP BEFORE YOU RUN ANY QUERY THAT MODIFIES DATA IN YOUR DATABASE
Should go without saying.
Second
This method would probably give professional DBAs a heart attack. But it works in specific instances as mentioned above, on static tables.
Here it is:
Code:
USE DATABASE --Replace with whatever db youre updating eg: SRO_VT_SHARD GO SET IDENTITY_INSERT TableName OFF --Replace with the table youre updating eg: _RefSkill MERGE DATABASE.dbo.TableName dest --Replace with the multipart reference to your table eg: SRO_VT_SHARD.dbo._RefSkill USING (SELECT * FROM SRO_VT_SHARD_BACKUP.dbo.TableName) AS src --Replace with the multipart reference to your backup table eg: SRO_VT_SHARD_BACKUP.dbo._RefSkill ON dest.UniqueIdentifier = src.UniqueIdentifier --Replace with the unique identifier columns in your table. (The one that is auto incremented and that you aren't allowed to change) In the case of _RefSkill it's dest.id = src.id WHEN MATCHED THEN UPDATE SET dest.ColumnName1 = src.ColumnName1, --Replace with the columns you want to update. eg: dest.Param4 = src.Param4 dest.ColumnName2 = src.ColumnName2; --Replace with the more columns you want to update. eg: dest.Param4 = src.Param5
That being said, it's ghetto and not recommended. If you happen upon this guide before you fuck something up give RoyalBlade's method a shot instead and use that in the future to make and test changes.
A BETTER METHOD
Code:
EXEC SP_RENAME _RefSkill, _RefSkillReal; --Renames the RefSkill table to _RefSkillReal SELECT * INTO _RefSkill FROM _RefSkillReal; --Recreates the _RefSkill table from the data in _RefSkillReal
Code:
DROP TABLE _RefSkill; --Drop the table SELECT * INTO _RefSkill FROM _RefSkillReal; --Remake it fresh from the backup
Once your change is confirmed working you can create a query for your changes and then restore the original table and run the query to change things legitimately.
Code:
DROP TABLE _RefSkill; --Pretty self explanatory EXEC SP_RENAME _RefSkillReal, _RefSkill; --Renames the real _RefSkill table back as it should be
Thanks to RoyalBlade's original post: