Import database (SQL file) in SQL Server Management Studio

46,291

If you have a .sql file which contains SQL statements, you can just copy and paste the contents (or open the file in a query window) and run it. This assumes it has all of the create table etc. statements to create the schema/structure and not just insert statements for the data.

Check the top of the file to make sure that it is first selecting the correct database, if not add a USE statement to select the correct database.

You didn't say how big the file was, but if it is quite large and has the insert statements (data as well as schema), then you'll probably want to run by CLI using sqlcmd command. Much faster and SSMS won't freak out.

Another alternative option to running the .sql file/code is to set up a data source for mysql and just use odbc to access the database itself.

Bear in mind that there are real and very annoying differences between mysql and t-sql that can make migration a pain. If you're just creating a few tables, it may not be an issue, but if there are a ton of tables with lots of fields of different data types, you may run into issues.

Share:
46,291
Matt
Author by

Matt

Just an avid coder

Updated on December 18, 2020

Comments

  • Matt
    Matt over 3 years

    I've created the structure of my database first in PhpMyAdmin and exported it to a .sql file. Now I'm looking everywhere in SQL Server Management Studio where I can import/add the data in a new database.

    Does anybody where to look or what to click? I'm using the 2014 version (CTP2)