简体   繁体   English

如何基于sql脚本创建新数据库

[英]how can i create a new database base on a sql script

I have generate a "schema only " database script for my staging database, using sql server 2008 r2 . 我已经使用sql server 2008 r2为我的登台数据库生成了“仅模式”数据库脚本。 now i need to execute the script to create the same database including (table, column, keys, etc) inside the production server. 现在,我需要执行脚本以在生产服务器内部创建相同的数据库,包括(表,列,键等)。 so my question i how i can execute the script inside the production server. 所以我的问题是我如何在生产服务器中执行脚本。

Second question; 第二个问题; currently i have generate the script to include only the schema, but i have some look-up tables which i need to move its data from staging to production. 目前,我已经生成了仅包含架构的脚本,但是我需要一些查询表,需要将其数据从暂存阶段转移到生产阶段。 so my question is how i can generate a script that copy the schema or the whole database , and also copy the data for specific tables ? 所以我的问题是我如何生成一个脚本,该脚本可以复制架构或整个数据库,还可以复制特定表的数据?

Thanks 谢谢

for your first question : 对于第一个问题:

you have to create your data base manualy if your scrip have only tables shema and open new query window and run it 如果您的凭证只有表shema并打开新的查询窗口并运行它,则必须手动创建数据库

for your second question : 对于第二个问题:

from sql server managment studio you have to do Generate script in Tasks then choose your tables then in Advanced there's Type of data script you have to shoose Schema only or data or Scema with data 从sql server managment studio中,您必须在Tasks中执行Generate script,然后选择表,然后在Advanced中,您必须只选择Schema或data或Scema with data的Type of data script

More explanation 更多说明

I found this link to explaine generate script, and in the window of Choose Object you can select Select specific database objects and select only the tables you want 我找到了此链接来解释生成脚本,并且在“ Choose Object ”窗口中可以选择“ Select specific database objects然后仅选择所需的表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM