[英]How to backup Sql Server to sql file?
在“Back UP”中我只得到一个bak文件,但我想创建.sql文件
Use SQL Server's Generate Scripts commend 使用SQL Server的Generate Scripts表示
CREATE
and INSERT
statements for all table data selected in bullet 2. CREATE
和INSERT
语句。 Ok, I read through most of these, but I had no "advanced button". 好的,我通读了大部分内容,但我没有“高级按钮”。 But, there is still a way to do it, it's just a little hard to find, so here you go:
但是,还有一种方法可以做到,它只是有点难找,所以在这里你去:
This is a possible duplicate of: SQL script to get table content as "SELECT * FROM tblname" 这可能是以下内容的重复: SQL脚本将表内容作为“SELECT * FROM tblname”获取
To do a full database backup to File/Query you can use the 'Generate Scripts...' option on the Database. 要对文件/查询执行完整数据库备份,可以使用数据库上的“生成脚本...”选项。
Open SQL Server Management studio, right click on the database and choose 'Tasks->Generate Scripts...' 打开SQL Server Management工作室,右键单击数据库并选择“任务 - >生成脚本...”
Then use the wizard to backup the database. 然后使用向导备份数据库。 You can script the whole database or parts of it.
您可以编写整个数据库或部分数据库的脚本。 Two important options: In the 'Advanced' section, you will probably want to ensure 'Type of backup = 'Schema and Data' and the 'Script Statistics' is on.
两个重要选项:在“高级”部分,您可能希望确保“备份类型='架构和数据'和”脚本统计信息“已启用。
This will produce a *.sql file that you can use as a backup that includes the schema and table data. 这将生成一个* .sql文件,您可以将其用作包含架构和表数据的备份。
您可以从数据库生成脚本,请参阅http://msdn.microsoft.com/en-us/library/ms178078.aspx
If you want to create a script of your database you right-click on the databases and Generate Scripts (it's in different sub-menus depending on what version of SQL and Enterprise Manager / SQL Server Management studio you're using). 如果要创建数据库脚本,请右键单击数据库并生成脚本(它位于不同的子菜单中,具体取决于您使用的SQL和企业管理器/ SQL Server Management工作室的版本)。
That will, however, only get you the database objects. 但是,这只会获得数据库对象。 It will not generate scripts for data.
它不会生成数据脚本。 Backing up a database will give you all of the database objects as well as the data, depending on what recovery model your database is set to.
备份数据库将为您提供所有数据库对象和数据,具体取决于数据库设置的恢复模型。
This fellow may have achieved what you are trying to do by creating the backup, and then restoring it and giving it a new name. 这个人可能通过创建备份,然后恢复它并给它一个新名称来实现你想要做的事情。
This approach copies the data along with all of the database objects. 此方法将数据与所有数据库对象一起复制。
If you want a file with insert statements for your data have a look here: 如果您想要一个包含数据插入语句的文件,请查看:
This procedure generates INSERT statements using existing data from the given tables and views.
此过程使用来自给定表和视图的现有数据生成INSERT语句。 Later, you can use these INSERT statements to generate the data.
稍后,您可以使用这些INSERT语句来生成数据。 It's very useful when you have to ship or package a database application.
当您必须运送或打包数据库应用程序时,它非常有用。 This procedure also comes in handy when you have to send sample data to your vendor or technical support provider for troubleshooting purposes.
当您必须将样本数据发送给供应商或技术支持提供商以进行故障排除时,此过程也会派上用场。
http://vyaskn.tripod.com/code.htm#inserts http://vyaskn.tripod.com/code.htm#inserts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.