Today encounter a situation, it is to copy the table structure mssql table to the new table which, in the online search some information, the solution is as follows:
1, select * into the database name .dbo. The new table names from the database name .dbo. Original name of the table where 1 = 0
2, hit Oldtable -> All Tasks -> Generate SQL Scripts -> Options -> Select "Writing a primary key, foreign key, default values and check constraints script" -> Settings Format -> just check "for the each object is generated CREATE <Object> command "-> General -> preview -> then copy the SQL statement to see -> Off -> click on the toolbar tools -> SQL query analyzer - > paste -> is modified oldtable NewTable -> press F5 to execute -> complete
. 3, CREATE TABLE SELECT * FROM new table Old table WHERE 1 = 2 or new table CREATE TABLE LIKE old table
After measurement.
1, only copy table field, Remarks fields, default values, etc. are copied, however, and give up.
2, generate SQL scripts -> Options, this option did not find where, give up.
3, this is available on Oracle, in mssql is reported grammatical mistakes, give up.
Later, to find a solution on MSDN, as shown below, it has been tested and is available now to share out the following steps.
-
Make sure you're connected to where you want to create a table in the database and select the database in the Object Explorer.
-
In Object Explorer, right-click the "Table" and then click "New Table" .
-
In Object Explorer, right-click the table you want to copy, then click the "Design" .
-
Select the column in an existing table, in the "Edit" menu, click "Copy" .
-
Switch back to the new table and select the first row.
-
In the "Edit" menu, click "Paste" .
-
In the "File" menu, click "Save name the Table" .
-
In the "Select name" dialog box, type a name for the new table and click "OK" .
Reproduced in: https: //www.cnblogs.com/ushou/archive/2013/04/23/3037929.html