Portal Home > Knowledgebase > cPanel > Database table mover (restore backup)


Database table mover (restore backup)




-- remove bad table
DELETE FROM [ DATABASE-NAME ].[dbo].[ TABLE-NAME ];

-- CREATE new table from create script

-- allow identity inserts
SET IDENTITY_INSERT [ DATABASE-NAME ].[dbo].[ TABLE-NAME ]  ON;

-- insert into new table
INSERT INTO [ DATABASE-NAME ].[dbo].[ TABLE-NAME ] (
  --- column list - acquire from script to SELECT
  )     
  SELECT 
  --- column list as above
    FROM [ DATABASE-NAME2 ].[dbo].[ TABLE-NAME ];

-- turn off allow identity insert
SET IDENTITY_INSERT [ DATABASE-NAME ].[dbo].[ TABLE-NAME ]  OFF;


Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article