Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force a restore and load programs locking the db 1

Status
Not open for further replies.

mikelawrence

Programmer
Sep 19, 2001
68
GB
I'm using SQLServer 2000. Sometimes when I want to do a restore it fails as I cannot get exclusive access. Is there anyway to force the backup through? I am just doing it manually through EM at the moment but I would also like to know how to do it if i set up a scheduled job.

As an entirely separate issue I run a PERL program to upload data into my db. When it runs it pretty well freezes anyone else's access to the db. Would this to be do with locking the tables? I am happy for it to run slower but would like other people to be able to use the db. Any ideas on how to best to do this?

Also how do i see who is logged into my server? I run Windows 2003 so is there a way of seeing there or do i use the Current Activity in the Management Tools of EM?

There is so much I don't know!

I appreciate any help,

Mike
 
1. Are you trying to restore the database over one already existing?

2. I don't use PERL, but that is likely causing a problem. Check the BOL (use the index tab) and look for the tablehint NOLOCK.

3. Run this in Query Analyzer EXEC SP_WHO2

-SQLBill

Posting advice: FAQ481-4875
 
Yep, the db is existing, i want to periodically replace the the test db with the latest backup of the live db so the data is uptodate to test against.

Thanks for the other advice, I'll look into those 2 things

mike
 
Then you have to kick everyone off.

First issue the command
Code:
ALTER DATABASE dbname SINGLE_USER

Then restore the database and you might have to use the REPLACE option.

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top