Sql Table Backup Restore
The easiest way to backup a table is using an SQL query.
Using the GO statement causes SQL to process your groups of statements sequentially instead of processing them in parallel. If you try to create a table that exists; but you were dropping it... you get the idea; it gets messy. Using the GO takes care of that.
=== Turn on bulk copy. ===
EXEC sp_dboption EVEREST_HMC99,'select into/bulkcopy', true
GO
=== Drop the destination backup table. ===
if exists (select * from dbo.sysobjects where id = object_id(N'[bkpItems]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [bkpItems]
GO
=== Backup the table. ===
SELECT *
INTO bkpItems
FROM Items
GO
=== Restoring the backup table using UPDATE for existing records. ===
=== Sample column names used below. ===
UPDATE Items
SET Items.SerialId = bkpItems.SerialId,Items.Cost = bkpItems.Cost
FROM bkpItems,Items
WHERE bkpItems.[ID]=Items.[ID]

0 Comments:
Post a Comment
<< Home