Is there a quick and easy way to duplicate a table in SQL-Server? I just want to make a temporary table from table A because I need to refresh table B (which will interfere with the foreign keys).
I know this isn't a ridiculous task to do manually, but it seems like there should be a nice way to do it.
Edit: To clarify, I want to duplicate the table definition, not the actual data.
Try this?
SELECT
*
INTO
#temp
FROM
myTable
WHERE
1=0
It won't duplicate constraints, indexes, etc. But it should duplicate the data-types and field names.
Wouldn't it be a better approach to just temporarily disable constraints while you are doing your refresh
ALTER TABLE X NOCHECK CONSTRAINT ALL
-- Refresh SQL
ALTER TABLE X CHECK CONSTRAINT ALL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With