Link to home
Start Free TrialLog in
Avatar of Blowfelt82
Blowfelt82

asked on

Recreate table and contents with T-SQL

I need to copy a tables contents to a temporary table and then drop, recreate and repopulate the original table. I need to do this for a lot of tables so a generic solution would be ideal i.e. one where I only have to edit the table name.
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this.

RecrateTable store procedure which takes table name as input
and uses CreatTable function to create table with constraints
CreateTable.sql
RecreateTable.sql
Avatar of Blowfelt82
Blowfelt82

ASKER

Thanks