Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import .sql file into SQL Server Express

I have a plain sql file with some SQL INSERT statements.

Is it possible to import it in my local SQL Server Express instance?

like image 489
ggarber Avatar asked Jun 30 '11 13:06

ggarber


People also ask

How do I import a .SQL file into SQL Server?

Open SQL Server Management Studio. Connect to an instance of the SQL Server Database Engine or localhost. Expand Databases, right-click a database (test in the example below), point to Tasks, and click Import Flat File above Import Data.

How do I run a SQL script in SQL Server Express?

Click Query > Connection > Connect to connect to the server that contains the database you want to access. Select the appropriate StarTeam Server database. Open the tuning script, by choosing File > Open > foldername\scriptname. Execute the script, by clicking the Execute button on the toolbar or by pressing F5.


2 Answers

You can use Management Studio Express edition. You can download the latest version here - which will work against SQL Express 2005, 2008 and 2008 R2.

If you don't want to install SSMSE then you can use sqlcmd at a command prompt, e.g. something like this (assuming Windows auth and an instance called "SQLEXPRESS"):

sqlcmd -S .\SQLEXPRESS -E -i "C:\path\file.sql"
like image 176
Aaron Bertrand Avatar answered Oct 26 '22 12:10

Aaron Bertrand


The easiest way would be simply open the file in the Sql Management Studio and run it. Since the target table is already created, of course.

like image 22
RMalke Avatar answered Oct 26 '22 11:10

RMalke