[英]How to copy data and structure of table from one table to another?
In my first database named 'sshopping' has two tables IndiaStates and IndiaCity. 在我的第一个名为“购物”的数据库中,有两个表IndiaStates和IndiaCity。 I want to copy these both table in new database 'jaijinendera' .
我想将这两个表都复制到新数据库'jaijinendera'中。
IndiaStates has columns StateID (Primary Key) and StateName IndiaStates的列为StateID(主键)和StateName
IndiaCity has columns CityID(Primary Key) , StateID (Foreign Key),CityName IndiaCity的列为CityID(主键),StateID(外键),CityName
I used the query something like this 我用这样的查询
Insert int jaijinendera..IndiaStates select * from sshopping..IndiaStates
Insert int jaijinendera..IndiaCity select * from sshopping..IndiaCity
this has copied the data but not the keys (structure). 这已经复制了数据,但没有复制键(结构)。 What query should i made to copy proper structure and data from sshopping to jaijinendera
我应该进行什么查询才能将适当的结构和数据从购物复制到jaijinendera
Try using the SQL Server Generate script. 尝试使用SQL Server生成脚本。
Right click on DB where you want to export table structure and data. 右键单击要导出表结构和数据的数据库。 Select Task and generate script.
选择任务并生成脚本。 follow the wizard.
按照向导。 Select the object or entire database in the select object you want to generate script.
在要生成脚本的选择对象中选择对象或整个数据库。 Click on the Advance to select schema only (for structure)/ data only for data and schema and data for both.
单击高级以仅选择模式(对于结构)/仅数据作为数据以及模式和数据。
generate the script to file or clipboard. 生成脚本文件或剪贴板。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.