SQL Server 2005 - Export table programmatically (run a .sql file to rebuild it)(SQL Server 2005 - 以编程方式导出表(运行 .sql 文件以重建它))
问题描述
我有一个带有表的数据库,客户有一些数据
我在办公室有另一个数据库,一切都一样,但我的表客户是空的
如何在 SQL Server 2005 (T-SQL) 中创建一个 sql 文件,该文件从第一个数据库中获取表 Customers 上的所有内容,创建一个 buildcustomers.sql,我压缩该文件,将其复制到网络上,执行它在我的 SQL Server 中,瞧!我的桌子顾客已满
如何对整个数据库执行相同操作?
I have a database with a table Customers that have some data
I have another database in the office that everything is the same, but my table Customers is empty
How can I create a sql file in SQL Server 2005 (T-SQL) that takes everything on the table Customers from the first database, creates a, let's say, buildcustomers.sql, I zip that file, copy it across the network, execute it in my SQL Server and voila! my table Customers is full
How can I do the same for a whole database?
推荐答案
此功能已内置到 Sql Server Management Studio 2008 中.
This functionality is already built in to Sql Server Management Studio 2008.
只需下载试用版,然后只安装客户端工具(不应过期).使用 Management Studio 2008 连接到您的 2005 数据库(向后兼容).
Just download the trial and only install the client tools (which shouldn't expire). Use Management Studio 2008 to connect to your 2005 database (its backwards compatible).
- 右键单击您的数据库
- 选择任务 > 生成脚本
- 按下一步,再次选择您的数据库
- 在选择脚本选项"屏幕上,有一个名为脚本数据的选项,它将为您的所有数据生成 SQL 插入语句.
- Right click your database
- Choose Tasks > Generate Scripts
- Press Next, select your database again
- On the 'Choose Script Options' screen, there is an option called Script Data which will generate SQL insert statements for all your data.
(注意:对于 SQL Server Management Studio 2008 R2,该选项称为要编写脚本的数据类型",是常规"部分的最后一个.选项为仅数据"、架构和数据"以及仅模式")
(Note: for SQL Server Management Studio 2008 R2, the option is called "Types of data to script" and is the last one in the General section. The choices are "data only", "schema and data", and "schema only")
这篇关于SQL Server 2005 - 以编程方式导出表(运行 .sql 文件以重建它)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 2005 - 以编程方式导出表(运行 .sql 文件以重建它)


- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01