×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Restore Database Using .Net Program

Restore Database Using .Net Program

Restore Database Using .Net Program

(OP)
I'm trying to restore a DB using a stored procedure called from a .Net program and would like a little help.

CODE

-- Error checking removed
ALTER DATABASE Cemetery1 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
RESTORE DATABASE Cemetery1 FROM DISK = @RestoreFileName
ALTER DATABASE Cemetery1 SET MULTI_USER; 
I get an error saying it cannot do this because it is use by this session. I understand that because I accessed the stored proc that is in the DB I am trying to restore. It also says I should use the master DB for this. Does that mean I have to set up a user and the stored procedure in the master DB? Then open the master DB from the .Net program and run the master DB proc. I'm a little worried about what permissions I would have to give this user in the master DB. Any guidance on how to accomplish this would be appreciated.

Auguy
Sylvania/Toledo Ohio

RE: Restore Database Using .Net Program

In order for a user to restore a database, there are certain server level permissions required. Assuming your user already has those permissions, then they will already be allowed to connect to master to perform certain operations (like restoring a database).

Basically, what I'm saying is that you don't need to do anything special to give the user permissions to the master database. Simply connect to that database and do the restore.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom

RE: Restore Database Using .Net Program

(OP)
Thanks George, I'm also looking into SqlCmd utility.

Auguy
Sylvania/Toledo Ohio

RE: Restore Database Using .Net Program

(OP)
I'm assuming I have to put the stored proc into the master database. Doses that sound right?

Auguy
Sylvania/Toledo Ohio

RE: Restore Database Using .Net Program

yes

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom

RE: Restore Database Using .Net Program

(OP)
Thanks again George, great answers as always!

Auguy
Sylvania/Toledo Ohio

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close