Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Run SQL script to populate db

Author  Topic 

QBALL
Starting Member

9 Posts

Posted - 2009-09-21 : 12:41:59
Hi

I have been given an SQL script file to run against my new MDF database. The db is currently empty no tables nothing.

Im attempting to apply the script in server manager studio express.

1. I connect to my server group and highlight the db I want to populate.
2. open my sql script in the query window and then click execute.

Unfortunately when i check my db nothing has been added, no tables or fields.

Could someone please point me in the right direction.

Many Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-21 : 12:48:57
Refresh your screen. If that doesn't work, make sure your database is selected in the drop-down menu before you click execute otherwise your objects were created in the wrong database.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

QBALL
Starting Member

9 Posts

Posted - 2009-09-22 : 06:05:35
Thanks for the tip.
You was correct I populated the wrong db.

In my sql server management databases I have a folder with system databases and then my db I want to populate, even when I highlight the db I want to populate it populates the first db in the system db folder master.mdf

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-22 : 12:54:02
Make sure the database dropdown list specifies the one you want.

Or simply add this to the top of your script:

USE dbNameGoesHere
GO

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -