0

I want to open an existing database from an .mdf file in SSMS but I am not able to attach it. It's giving the following error:

The server principal "......" is not able to access the database "model" under the current security context. (.Net SqlClient Data Provider)

Details: Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)

What could be causing this problem and how do I solve it?

Community
  • 1
  • 1
Surabhi Pandey
  • 4,058
  • 4
  • 18
  • 25
  • If you try to add the model.mdf it will generate problems. Model,mdf is a SQL SErver system database. Try backing the original up and then restore it. See https://technet.microsoft.com/en-us/library/ms190749(v=sql.105).aspx – Danie Schoeman Jan 11 '17 at 08:29
  • I solved this above error by running it as administrator but now when i am attaching the .mdf file from explorer I am getting this below error : Failed to retrieve data An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo) CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file 'E:\...(Microsoft SQL Server, Error: 5123) – Surabhi Pandey Jan 11 '17 at 08:38
  • You still did not say if you are tried to attach the model db (model.mdf) or another database... – Danie Schoeman Jan 11 '17 at 08:52
  • Another database from my project folder – Surabhi Pandey Jan 11 '17 at 08:53
  • Do you have read/write access to the folder and to the file in question? Are you sure that another SQLServer Express process do not have it attached already? If so, detach it first/or copy it to another location and then attach it. Again check folder and file access. – Danie Schoeman Jan 11 '17 at 09:06
  • I have a doubt Please clear I have opened that project in visual studio and there database is running properly and than I started opening my same databse in MS sql Management studio so here database is not opening its giving the error that .mdf file in running with another process. So we can open our database at a time in either visual studio or ms sql server managemnet studio??? Is It?? – Surabhi Pandey Jan 11 '17 at 09:29
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/132891/discussion-between-surabhi-pandey-and-danie-schoeman). – Surabhi Pandey Jan 11 '17 at 09:33

0 Answers0