0

I have a database schema sitting in SQL Server 2017 running on Ubuntu. I have a separate 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. 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. All I have is sqlcmd running on the instance with 2017 version. So can I run "create scripts" to get the structure of the database and store in a single .sql file.?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mad_
  • 8,121
  • 2
  • 25
  • 40
  • 2
    In a word, no. `sqlcmd` can run scripts, but it can't create them. For Linux, you want [`mssql-scripter`](https://github.com/Microsoft/mssql-scripter) (disclaimer: no personal experience). – Jeroen Mostert Jul 18 '18 at 20:02
  • @JeroenMostert Thanks. I was able to create the scripts using mssql-scripter. I had to make some changes in the scripts but was very much helpful. – mad_ Jul 19 '18 at 18:27

1 Answers1

0

Check this answer: How to use sqlcmd to create a database

Here you go:

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

More options can be found in SQL Server books online.

CR241
  • 2,293
  • 1
  • 12
  • 30
  • Thanks but I really need the other way round. I need the schema scripts to be generated which I can use in other lower version database to create the exact same schema. If that makes any sense to you. – mad_ Jul 19 '18 at 13:11