When using the right-click option on 'databases' the 'Attach' option is not listed.
CODE EXAMPLE WITH ERROR
I'm wondering if someone else has seen this before.
I also get an error when I run this code instead:
CREATE DATABASE testdb
ON (FILENAME = 'C:\databasefile.mdf')
FOR ATTACH_REBUILD_LOG
GO
My SQL Server version is
select ##version
Microsoft SQL Azure (RTM) - 12.0.2000.8 Jul 10 2018 21:38:33
Attach option is missing
Related
From a Windows Server 2012 / SQL Server 2014, I backed up a database to a NNNN.bak file on a network drive. When I log in to my new Windows Server 2019 / SQL Server 2019 and try to restore that, I get the famous
No backupset selected to be restored
error on the upper-left corner of the screen when I select a NNNN.bak.
I tried several things like checking/adding the file extension .BAK, restore from a local drive, different checkboxes in "General", "Files", "Options" menu.
Important: with the same exact conditions 5 other databases got restored and the other four are not cooperating within the same week.
I checked my user permissions inside databases and both SQL servers. I am an administrator with almost all privileges.
I tried restore verifyonly... and restore header... etc
Using the network path provided by the company R:\erts..\nnn... failed. restore succeeded using server on the same network with \\Qdata...\nnn.. path as shown in the screenshot.
I have followed the steps listed in this answer from another thread but when I try to click Next > on the destination screen I get the error:
TITLE: SQL Server Import and Export Wizard
------------------------------
The operation could not be completed.
------------------------------
ADDITIONAL INFORMATION:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I have:
Installed PostgreSQL ODBC Driver on the source server
Added in ODBC Data Source Administrator (32-bit) a PostgreSQL Unicode driver User DSN (also tried a System DSN) source named postgres (settings are all correct as the Test runs fine)
Inside SSMS right-clicked on the database I want to export from and selected Tasks -> Export Data
Chose SQL Server Native Client on the source screen and entered the credentials for SQL Authentication
Chose .NET Framework Data Provider for ODBC as the destination driver
Entered the below connection string
Hit Next > and the error pops up
My connection string is: Dsn=postgres;Driver={PostgreSQL Unicode};server=<servername>;port=<port>;database=postgres;uid=<user>;pwd=<pass> (the things between <> are actually filled out, just redacted for post).
Just in case it matters, I am trying to export from my SQL database into my PostgreSQL database.
Here are versions for everything:
SQL Server Management Studio: v17.5 (About window shows this and below value)
Microsoft SQL Server Management Studio: 14.0.17224.0
Source Database: SQL Server 11.0.2100.60
Source Server: Windows Server 2012 R2
Source ODBC: 32-bit
Destination Database: pgAdmin 3.0
Destination Server: Windows Server 2012 R2
I am trying to attach the AdventureWorks2012_Data.mdf database file to my SQL Server 2012 database.
I am getting this error:
TITLE: Microsoft SQL Server Management Studio
Attach database failed for Server 'USER-PC'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.3000.0+((SQL11_PCU_Main).121019-1322+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorksDW2012_log.ldf". Operating system error 2: "2(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)
Maybe the message is clear that I don't have the .log file and yes I don't have it. But is it necessary to have it? Or is there is another thing? How can I solve that please?
This is a common error that anyone could encounter when you don't have any *.LDF log file for your database, like the AdventureWorks database. SQL Server complains about the *.LDF log file (typically associated to a database *.MDF file) that is missing.
Execute the following T-SQL query to attach the database considering only the *.MDF file:
USE [master]
GO
CREATE DATABASE [AdventureWorksDW2012] ON
( FILENAME = N'C:\Users\User\Desktop\ARPAD\AdventureWorks2012_Data.mdf' )
FOR ATTACH
GO
or remove the connection to the *.LDF log file (a new *.LDF file will be created for the database) through SQL Server Management Studio as shown in the screenshot below:
UPDATE
You get the error:
The database 'AdventureWorksDW2012' cannot be opened because it is version 706. This server supports version 661 and earlier. A downgrade path is not supported. Could not open new database 'AdventureWorksDW2012'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)
because you're trying to attach a SQL Server 2012 (version 706) database file to SQL Server 2008 istance (version 661). For this reason, you cannot perform this downgrade. Download the AdventureWorks2008 database for your SQL Server 2008 istance instead, or upgrade your SQL Server istance with the latest version.
The version of your SQL Server istance is indeed SQL Server 2008: Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64) Apr 22 2011 19:23:43 Copyright (c) Microsoft Corporation Express Edition with Advanced Services (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1).
Download and install SQL Server 2012 Express to solve the problem.
The key is this line (edited for clarity):
Unable to open the physical file
"C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorksDW2012_log.ldf".
Operating system error 2:
"2(failed to retrieve text for this error. Reason: 15105)".
(Microsoft SQL Server, Error: 5120)
According to this page, operating system error 2 is "File Not Found". Based on this, I would guess that either, A) the file is not there , or B) the name or path is misspelled.
(I'm too slow the answer above is what I'm talking about)
FYI This answer assumes your using the attach a database dialog.
Make sure you've told sql manager where the ldf file is too. It will fill in an entry for a log even if you aren't attaching the log with the mdf.
You'll see it in the box below the one with the add button. You can just remove the log from the attach if you don't have it. Sql will make a new log and you can move merrily along the way.
I want to delete the saved usernames and passwords displayed in the "Connect to Server" screen.
In the internet (for example here) I've read that I should delete the file %APPDATA%\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin, but inside of %APPDATA%\Microsoft\Microsoft SQL Server\ I can't find a folder 100 (only 90and 110). And if I start a search, I also can't find the file SqlStudio.bin in one of these other two folders.
I'm using Windows 7 and version 11.0.1750.32 of Microsoft SQL Server Management Studio.
When digging further into this I found the file at:
%APPDATA%\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
The "100" part of the path is dependent on the version of SQL Studio:
90 = v9 = SQL Server 2005
100 = v10 = SQL Server 2008
110 = v11 = SQL Server 2012
Since you have v11 installed (SQL Server 2012) the file will be found here:
%APPDATA%\Microsoft\Microsoft SQL Server\110\Tools\Shell\SqlStudio.bin
When I press the Add... button in the Attach Databases window I get the following error:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
The server principal "callisto\dotancohen" is not able to access the database "model" under the current security context. (Microsoft SQL Server, Error: 916)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.1750&EvtSrc=MSSQLServer&EvtID=916&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
The mention of "current security context" led me to believe that this is a permissions issue. However, when I open SQL Management Studio as Administrator I can in fact open the Add... dialogue but it will not let me browse to the C:\Users\dotancohen directory in which my database .mdf file is stored.
This is with SQL Management Studio 2012 RC0 on Windows 7 32 bit. The database .mdf file that I am interested in opening is a 2012 file and 2008 will not open it (my connect.Open() statement fails with 2008, works with 2012). Thank you.
Note that I am not interested in opening SQL Management Studio as administrator to access the database, but rather I am interested in resolving the issue with the user-opened SQL Management Studio to access the database as a regular user. My C# application running in debug mode can open this database without escalated privileges.
It turns out that this is a known bug with SQL Management Studio 2012, or at least the Beta and RC0 version.
By the way, here is the link to file bugs against Microsoft products. Not all MS products can have bugs filed against them at all times, so if the product that you need to file an issue is unavailable for bugs at the moment, try again in a month or two.
It is some MYSQLSERVER agent issue, I just restarted my VM/Machine and it started working perfectly.