How to create a copy of a table in SQL Server Enterprise Manager?

This is one of those “I probably should know about it, but I don't have” questions. How to create a copy of a table in Enterprise Manager? Do not export data to another database, just make a copy of the table in the same database. At the moment, I don't care if the data is coming in or not, but the definition of the table must be duplicated.

If I do Ctrl + C in the selected table and paste the results into a text editor, it gives me the Create Table instruction, which looks promising, but I can’t find any place to run this statement for life.

Edit: Please note that I am asking about SQL Server Enterprise Manager. This is not the same as SQL Server Management Studio. There is no “New Request” button, neither in the upper left corner, nor elsewhere. In fact, the word "query" does not appear anywhere in EM, except for the menu "Tools", and there is a link to the Query Analyzer.

+5
source share
6 answers

If you say 2000 enterprise manager: Tools → Query Analyzer Gives you a place to execute the query.

+5
source

Copy a table with all contents (without keys and restrictions)

select * into tablecopy from table 

Copy a table without content (without keys and restrictions)

select top 0 * into tablecopy from table 

, (), script, ( ). script, -,

insert into tablecopy select * from table

.

EDIT: , , - SQL Enterprise Manager, Query Analyzer, Management Studio.

+10
SELECT * INTO MyNewTable FROM MyOldTable

,

+9

:

SELECT *
INTO new_table_name
FROM old_table_name
+1

TSQL...

SELECT * INTO MyTableCopy FROM MyTable WHERE 1=2

EM, > > SQL Script.

+1

If you need primary keys, etc., right-click on the table, select "Script table as", then "Create in", then "New window". Change the table name to the copy name and run the script. Then you can choose according to other answers if you need data.

0
source

All Articles