views:

93

answers:

5

I have a .sql file I need to enter in to my database, but I can't find how to do it.

I'm using SQL Server Management Studio R2, but haven't found any options on how to add it.

When I try to attach it, I'm told that this file isn't a primary database file, so I can't do it...

EDIT: okay, I had the script execute. That worked.

+3  A: 

A .sql file is a script, not a database.

Brad
+1  A: 

A .sql file is usually a script (DML, DDL, other commands) which can be run against a database. It may create objects, databases, add or remove data. You can open it (File...Open) in SSMS (or view it in any text editor) and then execute it (after carefully reviewing the script).

Cade Roux
+4  A: 

A .SQL file is a script file that contain SQL commands. To run those commands you need to go to the menu: FILE, then OPEN and FILE..., browse and select the .SQL file and it will open it, you can then run it (F5). Make sure the current database is the one where you want those commands to occur within.

KM
+1  A: 

File->Open, browse to the file, load it. Make sure the right database is selected in the drop-down box above the editor. F5 to execute.

Fosco
+2  A: 

Will this work for you?

In Management Studio, click on menu File -> Open -> File -> navigate to the file.

After the file has opened, you can click F5 to run the SQL.

DOK