Link to home
Start Free TrialLog in
Avatar of paultran00
paultran00Flag for United States of America

asked on

SQL SERVER 2019: How do I make a copy of a table with data, primary key, foreign key, trigger, functions?

Hi,


In SQL SERVER 2019, when I want to make a copy of a table (as a backup), I use this command:


SELECT * INTO MyNewTable FROM MyTable


Problem is it only copies the data, and does not recreate other table attributes such as PRIMARY KEY, FOREIGN KEY, TRIGGER, FUNCTION, autoincrement number field, etc.


QUESTION: How do I make a copy of a table with data, primary key, foreign key, trigger, functions?

ASKER CERTIFIED SOLUTION
Avatar of Kusala Wijayasena
Kusala Wijayasena
Flag of Sri Lanka 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
Avatar of paultran00

ASKER

Thanks.