简体   繁体   English

如何使用sqlcmd创建SQL Server 2017数据库脚本

[英]HOW to create SQL Server 2017 database scripts using sqlcmd

I have a database schema sitting in SQL Server 2017 running on Ubuntu. 我有一个坐在Ubuntu上运行的SQL Server 2017中的数据库架构。 I have a separate SQL Server 2008 R2. 我有一个单独的SQL Server 2008 R2。 I need the database structure to migrate from 2017 -> 2008 R2 server and cannot find the right direction to start with. 我需要数据库结构从2017-> 2008 R2服务器迁移,并且找不到正确的方向。 I had created the backup and tried to restore but it seems we cannot restore in that fashion. 我已经创建了备份并尝试还原,但似乎我们无法以这种方式还原。 I think "create scripts" will do the job but I do not have management studio. 我认为“创建脚本”可以完成工作,但是我没有Management Studio。 All I have is sqlcmd running on the instance with 2017 version. 我所拥有的只是在2017版实例上运行的sqlcmd So can I run "create scripts" to get the structure of the database and store in a single .sql file.? 因此,我可以运行“创建脚本”来获取数据库的结构并存储在单个.sql文件中吗?

Check this answer: How to use sqlcmd to create a database 检查此答案: 如何使用sqlcmd创建数据库

Here you go: 干得好:

 sqlcmd -i C:\path\to\file.sql

More options can be found in SQL Server books online . 可以在SQL Server联机丛书中找到更多选项。

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

相关问题 使用 sqlcmd 创建表 || Azure SQL 服务器 - Create table using sqlcmd || Azure SQL Server 如何使用sqlcmd访问远程sql服务器? - How to access remote sql server using sqlcmd? 如何使用SQL Server数据库在Visual Studio 2017中创建安装文件 - How to create setup file in Visual Studio 2017 with SQL Server database 如何在带有图形数据库对象的 SQL Server 2017 中使用“生成脚本”? - How can I use 'Generate Scripts' in SQL Server 2017 with Graph Database Objects? 无法使用sqlcmd远程登录到SQL Server数据库 - Can't remotely login to a SQL Server database using sqlcmd 使用C#无法在Sql Server 2017中执行Sql脚本 - Unable to execute Sql scripts in Sql Server 2017 by using C# RoundhouseE(数据库迁移实用程序)是否支持在 SQLCMD 模式下运行 SQL Server 脚本? - Does the RoundhousE (database migration utility) support running SQL Server scripts in SQLCMD mode? 如何使用sqlcmd创建数据库 - How to use sqlcmd to create a database SQL Server数据库项目 - 创建更改脚本 - SQL Server database project - Create change scripts 如何在SQL Server 2017中使用MFA创建Azure SQL数据库的链接服务器 - How to create a Linked Server of Azure SQL Database with MFA in SQL Server 2017
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM