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
 Old Forums
 CLOSED - SQL Server 2005/Yukon
 Could not obtain exclusive lock on database model

Author  Topic 

gsgill76
Posting Yak Master

137 Posts

Posted - 2006-10-30 : 01:04:20
Hi

CREATE DATABASE nnee

throws error:

Msg 1807, Level 16, State 3, Line 1
Could not obtain exclusive lock on database 'model'. Retry the operation later.
Msg 1802, Level 16, State 4, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

what need to?

(I want to add, i created a SP in 'model' DB, after that i start getting this problem, but i deleted that, but still getting the same, before SP its working fine)

Regards,
Thanks.
Gurpreet S. Gill

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-04 : 03:27:56
You probably just have a connection that has model as the current database or you have the SP open in Enterprise Manager. Creating the SP in model won't cause that problem. Just make sure you close any connections that are using model before you try to create a new database.
Go to Top of Page

gsgill76
Posting Yak Master

137 Posts

Posted - 2006-11-04 : 05:22:54
1) I Restart the SQL Server Service
2) I Dissconnect & Reconnect the SSMS,
this solved the problem.

Is there any other way to do the same, i mean, without restart service/reconnecting SSMS ?

Regards,
Thanks.
Gurpreet S. Gill
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-04 : 16:21:07
You don't need to restart the SQL Server service, just disconnect and reconnect.
Go to Top of Page

gsgill76
Posting Yak Master

137 Posts

Posted - 2006-11-05 : 23:58:15
Hi snSQL
OK, its working without restarting the SQL Service.Just disconnect & reconnect works fine.
Is there any method, by which i can get rid of this problem, without disconnect & reconnect(i mean some T-SQL or somthing like that) ?
Regards,
Thanks.
Gurpreet S. Gill
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-06 : 11:56:34
Just change the database for your connection

USE anotherdatabase
Go to Top of Page

gsgill76
Posting Yak Master

137 Posts

Posted - 2006-11-07 : 03:07:17
No that doesnt work.
this is how i try
1) Create a SP in 'Model' DB
2) open other query editor(i am using SSMS)
3) write following commands
USE master
CREATE DATABASE DDFF
Returns same "Could not obtain exclusive lock on database model " error

I checked from the monitor the connection with the Model DB still exists. only 'USE' command dose not close the connection for 'Model' DB.
What the other wayout?

Regards,
Thanks.
Gurpreet S. Gill
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-07 : 04:39:32
1a) Create a SP in 'Model' DB
1b) USE AnotherDatabase
2) open other query editor(i am using SSMS)
...
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2006-11-07 : 05:30:56
Try -

USE master
GO
CREATE DATABASE DDFF


-------
Moo. :)
Go to Top of Page

gsgill76
Posting Yak Master

137 Posts

Posted - 2006-11-07 : 07:00:49
Hi Kristen & mr_mist

Both of the command doesnt work.(return same error)

The thing is the connection to the 'Model' DB still open. How can i drop/kill this, so that create database command runs fine?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-07 : 07:08:55
The connection to the model database needs to issue a USE command to change to a different database. Is that what you did?

Kristen
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2006-11-07 : 07:51:14
Here. Look.

1) Create a SP in 'Model' DB
2) open other query editor(i am using SSMS)
3) write following commands
USE master
GO
CREATE DATABASE DDFF


-------
Moo. :)
Go to Top of Page

gsgill76
Posting Yak Master

137 Posts

Posted - 2006-11-08 : 01:24:33
DONE!!!

Thanks to all.
Regards,
Gurpreet S. Gill
Go to Top of Page
   

- Advertisement -