SQL Server 2008 connection error - sql-server

Currently my project is running, however I connect same project database with SQL Server Management Studio which shows error
Failed to retrieve data for this request.
(Microsoft.SqlServer.Management.Sdk.Sfc)
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.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 'gg.mdf'. (Microsoft SQL Server, Error: 5123)
How can I fix this error?

You're probably creating a database with the same file names (.mdf) or a database which already exists on the SQL server.
I'm not sure what type of project you are talking about but try to change the physical file names of the database or removing the existing database from the server.

Related

Attempt to retrieve data for object failed for Server (Microsoft.SqlServer.Smo)

I have two databases, one hosted in Azure SQL Server and another one which is local on my own SQL Server instance. Both of these I manage using SSMS.
I wanted to see how I can backup the Azure DB and restore it on the local instance (where I currently have other databases as well, generated and managed by Entity Framework) of my SQL Server. For that purpose, I followed this video.
What I basically did was to export a .bacpac file and restore it on my local instance by making a reference to "Import Data-Tier application".
Everything went well. The content was successfully restored and I was able to browse through it. When I finished with my testing I manually deleted this new database.
From that moment on, I can not access my other databases at all. When I try to do whatever SQL query on those I get the following error:
Attempt to retrieve data for object failed for Server '**********'. (Microsoft.SqlServer.Smo)
ADDITIONAL INFORMATION:
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The connection is broken and recovery is not possible. The client driver attempted to recover the connection one or more times and all attempts failed. Increase the value of ConnectRetryCount to increase the number of recovery attempts. (Microsoft SQL Server, Error: 0)
Cannot open database "{THE NAME OF THE DB THAT I MANUALLY DELETED}" requested by the login. The login failed.
Login failed for user ******'. (Microsoft SQL Server, Error: 4060)

"Errors in the encryption library" When restoring Analysis Services Database

I have a AS Database (SQL Server 2005). I need to restore the database in a SQL Server 2014.
When I'm trying to restore the database I have this error:
File system error: The following error occurred while opening the file
'\?\C:\Program Files\Microsoft SQL
Server\MSAS12.MSSQLSERVER\OLAP\Data\Estadisticasnue.1.db\0.CryptKey.bin'.
Errors in the metadata manager. Processing for the database will be
disabled because an error occurred while loading the 'Estadisticasnue'
database cryptography key. One possible reason for this error is that
the service account has changed.
Errors in the encryption library:
Failed to decrypt sensitive data. Possibly the encryption key does not
match or is inaccessible because of improper service account change.
(Microsoft.AnalysisServices)
I don't know why I'm having this problem. If I use a database without password, the same problem appears.

How do I create a new SQL database in Visual Studio 2015 for the first time?

I'm very confused, when I try to create a new database in Visual Studio 2015 when I right-click --> Add new item --> SQL Server Database, I get an error saying "A network-related or instance-specific error occurred while establishing a connection to SQL Server." I think this means I don't have the SQL Server running, which is correct.
But when I try to start the SQL Server, it gives me the error "Windows could not start the SQL Server (SQLEXPRESS) on Local Computer) (Error code 17113). The event viewer gives me this error "Error 3(The system cannot find the path specified.) occurred while opening file 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\master.mdf' to obtain configuration information at startup. An invalid startup option might have caused the error. Verify your startup options, and correct or remove them if necessary." which I believe means that it won't start because there is no database.
So how am I supposed to create a database on a running SQL server when the SQL server won't run unless it has a database?
I don't know if this is relevant but I created it as an ASP.NET empty web site.

Importing a .cvs file into a detached .mdf?

I was asked to repost this question, due to the answers were not going the right directions.
I have a detached database similar to to Northwind.MDF I want to import a .CVS file into this MDF file. I have the mdf file as part of my Solution Explorer in vs2010 and I can look work with the data, just no way to import. In vs2010 I can use the Server Explorer and connect with no problems. the connection string looks like this:
Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ASPX\sdb1\customer.mdf;Integrated Security=True;User Instance=True
When I try to use any tool outside of vs2010 I cannot connect. Non of the sqlserver tools connect and give me an access denied, even when I try to attach the file from within Management Studio.
TITLE: Microsoft SQL Server Management Studio
Attach database failed for Server 'STEPHANS-PC\SQLEXPRESS'. (Microsoft.SqlServer.Smo)
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Unable to open the physical file "D:\ASPX\sdb1\customer.mdf". Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error: 5120)
This should not be this tuff to import data from a CSV.
You have to connect to your user instance database using an special connection string.
An user instance database is a sql express database based upon an mdf file (just what you have).
This link explains how to connect from SSMS to your User Instance Database:
How to: Connect to a User Instance

Can't connect to my own MDF file. Cannot open user default database. Login failed.Login failed for user... and other errors

SQLSEXPRESS service IS running!!
I have I program I wrote some time ago and it works. It was written in MS Visual Studio with local MDF file.
How is it possible to edit this file from Microsoft SQL Server Management Studio? I don't see this file in the list of globally connected databases.
If I try to attach this file with Visual Studio Wizard, I get message that such database already exists, but when I set arbitrary logical name, I get sharing violation.
How to reach MDF file?
EDIT 1
Now I found that my program also stopped to work.
The summary of results of different attempts to reach MDF file:
Program itself System.Data.SqlClient.SqlException (0x80131904): Cannot open user default database. Login failed. Login failed for user <username>. (windows user)
Visual Studio, Data source = Microsoft SQL Server, Logical Name = "" Error message: An attempt to attach an auto-named database for file
<filename> failed. A database with the same name exists, or
specified file cannot be opened, or it is located on UNC share.
Visual Studio, Data source = Microsoft SQL Server, Logical Name = SOMENAME Error message Unable to open the physical file <filename>. Operating system error 32: "32(The process cannot access the file because it is being used by another process )".
Cannot attach the file <filename> as database ‘SOMENAME’.
Visual Studio, Data source = Microsoft SQL Server Database File, Windows Authentication Error message: Cannot open user default database. Login failed. Login failed for user <username>.
Visual Studio, Data source = Microsoft SQL Server Database File, SQL Server Authentication Error message: Failed to generate a user instance of SQL Server. Only an integrated connection can generate a user instance. The connection will be closed.
Microsoft SQL Server Management Studio, Attach Database Error message: Unable to open the physical file <filename>. Operating system error 32: "32(The process cannot access the file because it is being used by another process)". (Microsoft SQL Server, Error: 5120)
MDF files are not intended to be used directly.
You may use them only through and with the help of SQL Server Engine.
Try this:
1- Create a database with the same name to mdf file.
2- Stop sql service
3- Go to the Data Carpet where is all mdf files and ldf , copy your original mdf file y replace.
4- Start the service
5- See in the management studio if the database still online there you go.
A .MDF database cannot be "opened".
It must be attached to an existing (and running) SQL Server instance.
If you have SQL Server Management Studio running, open a connection, and right click on databases. Choose "Attach" and point to the .MDF file. This will (attempt to) attach the database to the master database. If it works, the database will be visible in SSMS.

Resources