Title, online find some polite way, if do not want to toss, please see my method:
1, the first offline database, the purpose is to stop all links
2, choose to restore the database, if the tip of the log is incomplete, select the Database Properties option, overwrite the existing data.
On-line courtesy method:
Problem One solution:
Right-click Database--Properties-----restricted access, state---Select multiple-OK.
Problem Two solutions:
Method one (most convenient): Right-click the database--Properties----state-----Select single-> OK. and then restore.
Method two (most direct): Disconnecting database connections
Method three (most violent): Log off/Restart the database server
method Four (the most troublesome): Write code to modify the database related properties, although the trouble, sometimes still need to use, then use the time to study.
When you restore or delete a SQL Server 2008 database, the frequently-stewed occurrences are:
"Because the database is in use, you cannot gain exclusive access to the database", the Final solution is as follows
Key SQL statements:
ALTER DATABASE [datebase] SET OFFLINE with ROLLBACK IMMEDIATE
Run out and then
ALTER database [ datebase] Set online
Exclusive access to the database is not available because the database is in use---workaround for restoring or deleting a database (the ultimate solution)