SSMS 17.9 opens database on SQL Server 2014 instead of 2016 - sql-server

I have SQL Server 2014 and I did use it and have some db on it.
Yesterday I installed SQL Server Management Studio 17.9 and when I open it I just see the same db created on SQL Server 2014 (sql 12.0.2000.8).
But I want to create or restore some db that I created on SQL Server 2016 and I cant.
How should I tell SSMS 17.9 to use this path:
C:\Program Files\Microsoft SQL Server2016\MSSQL13.SQL2016SQL2016\MSSQL
Here I installed 2016.

You've created an instance named SQL2016SQL2016.
So you have to add the instance to the servername in the connection window like:
localhost\SQL2016SQL2016
An instance of the Database Engine is a copy of the sqlservr.exe
executable that runs as an operating system service. Each instance
manages several system databases and one or more user databases. Each
computer can run multiple instances of the Database Engine.
Applications connect to the instance in order to perform work in a
database managed by the instance.
Source: Database Engine Instances

Related

SQL Server Database Migration Assistant: Cannot connect to server

I am trying to migrate a database in-place (same PC) from SQL Server 2008 R2 Express to SQL Server 2019 Express, by using DMA (Database Migration Assistant). But I cannot connect to the target server (2008) during the "Assessment" task.
I have installed SQL Server 2019 as coexisting installation assigning the following instance names:
MSSQLSERVER (default name assigned during SQL Server 2008 R2 installation)
MSSQLSERVER2019 (different instance name assigned during SQL Server 2019 installation)
The PC is named DESKTOP1 and this results into the following server names:
DESKTOP1 for SQL Server 2008 R2
DESKTOP1\MSSQLSERVER2019 for SQL Server 2019
Both the server names work fine and I can normally connect to the servers by means of Management Studio.
The weird behaviour is that during the database assessment task, I couldn't connect to the source database server (DESKTOP1). Then I tried to go directly to the "Migration" task and I was able to connect. After this I went back to the "Assessment" task and (kind of magic) I was able to connect to the server DESKTOP1.
Do you have any clue about this issue? It looks like during Migration task there is something that enable the server connection.
Thank you!

An iIssue with SQL database attachment via Visual Studio

Me
An SQL newbie
My tools
VS Community 2017 v15.9.3 / C#
SQL Server 14.0.2002.14
SSMS 14.0...
What I want to do
I have a file, you say mydatabase.mdb, I am trying to create a connection to the database on SQL Server to access to it.
The database is not actually attached to SQL server, so I try to create my connection and attach it (correct?) using Server Explorer window on VS. I right click on "data connection" then choose "add connection"; in the "add connection dialog" I select the datasource "Database file of Microsoft SQL Server" and I give it the pathname of my file. Finally I hit "Test Connection".
The problem
On "Test Connection" I got this message:
The database 'mydatabase.mdb'cannot be opened because it is version 869. This server support version 852 and earlier.
Could not open new database 'mydatabase.mdb', CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file 'mydatabase.mdb' failed. A database with the same name exists, or specified file cannot be open or it is located on UNC share
My attempts
I connected the databse to SSMS. When I asked DB version to SSMS, I got: SQL Server 2016 (130). It is not congruent with MS error report. Anyway I changed database version to 2014, then I detached it from server and try again: same result.
Last note: if I create my connection on attached (by SSMS) database, and specifing directly the SQL server (not the file) as datasource, it seems to work. I could use this way, but I'd like to know the cause of the problem.
Can anyone help me?
You may have installed VS 2012, but you are using a SQL 2008 instance: Visual studio does not install SQL for you.
SQL Server 2008 databases are version 655. SQL Server 2008 R2 databases are 661. You are trying to attach an 2008 R2 database to an 2008 instance and this is not supported.
You need to upgrade your SQL instance to at least 2008R2 to open the file (but be aware that if you subsequently attach your existing DBs to the new instance, you won't be able to open then in SQL 2008 again either)
Your SQL Server version (the server that reported the error) is 2016, that is, it supports db version 852 and earlier.
The database that you try to attach is of version 869, this means it was created on SQL Server 2017.
You cannot attach it to an earlier version of SQL Server, so you need to upgrade your server to 2017 or install another instance of SQL Server, SQL Server 2017.
P.S. You CANNOT downgrade database version, i.e. when you said
I changed database version to 2014
it is not true.
Maybe you just change the compatibility level of database, but it's version is still 869.
Compatibility level means a version of cardinality estimator to use + some features, it has nothing to do with database version that refers to physical file format. Database version cannot be downgraded, only upgraded.
P.P.S.
I connected the databse to SSMS
You cannot "connect database to SSMS", you are connecting to server, and the database is also attached to server. And if you were able to attach this database to SQL Server, this means you have SQL Server 2017 already installed.
P.P.P.S. To detect your SQL Server version you shopuld execute this code: select ##version (from SSMS). It seems that you have at least 2 servers, 2016 and 2017 on your pc. You can verify this by opening SQL Server Configuration Manager, or you can use Windows Services to determine how many instances you have and what are their names. Then all you should do is to use the correct instance.
Here is the picture of my SQL Server instances, you can verify your instances by launching services.msc on your pc.

SQL Server Management Studio 2017 not showing databases that were created in SQL Server 2016

I had Express edition installed of SQL Server 2016. I needed to use SQL Agent Jobs. For that purpose I installed a patch of SQL Server 2016 enterprise edition but it didn't worked. After that I installed SQL Server 2017 Developer edition which showed me the SQL Agent Jobs node (which i wanted).
After installation i was able to see my databases in both servers 16 & 17 connected locally. Today when I logged into my system and connected the instance of the server I'm not able to see my databases. When i try to attach the data files located at:
C:\Program Files\Microsoft SQL Server\MSSQL13.SQLEXPRESS\MSSQL\DATA
it does not show the file in the popup to attach it. Although in the file explorer I can see the file. For reference I have added an image of the list of databases, i cannot find my databases in it.
Any help regarding it would be thankful.
Screenshot from both SCM's.
You installed second instance (2017). You need to connect to 2016 instance (using /instance_name) and then make a backup, and then restore backup (+transfer logins) on 2017 server, and finally uninstall 2016. Or detach files on SQL 2016 instance and reattach on 2017 + uninstall.
Alternatively you need to choose in-place upgrade 2016-> 2017 instead of installing a new instance.

SQL Server - Copy database from Server 2008 to Server 2012

I have two servers one in Denmark the other here in the UK. I need to make a copy of a database out of SQL Server Management 2008 (1st server) and place it in SQL Server Management 2012(2nd server). I have tried connecting to the remote server but have been getting difficulties so instead of connecting both up and doing it that way I was hoping there is a function like copy database which could do this for me. I have gone into tasks and copy database in SQL Server 2008 but in the Copy Database Wizard that appears it says "You can use this wizard to move or copy databases from an instance of SQL Server 2000 or later to an instance of SQL Server 2008". I'm looking for something like this that will work for Server 2012.
Copy your database file .mdf and log file .ldf and paste in your SQL Server
Install file in Programs Files->Microsoft SQL Server->MSSQL10.SQLEXPRESS->MSSQL->DATA.
Open SQL Server. Right-click on Databases then Select Attach... option.
You can create a backup with the Management Studio on the source and restore it on the target.
You need Management Studio 2012 to make this step. You can then create empty database on 2012 server. Right click on this empty DB->Tasks->Copy database..
Wizard will guide you. You should to this under 2012 Management Studio because it is compatible with 2008 Server - vice versa it will not work.
Of course, cleanest way is to do this via backup (.bak file - Tasks->Backup.. then on 2012 server Tasks->Restore->Files or FileGroups) but you need remote access (RDP) to the server.

Move all sharepoint 2007 databases to a new Sql Server

In our organization we have a Microsoft Sharepoint 2007 installed and configured on a Windows Server 2003 Standard Edition (32 bit).
The database had been installed and configured on a Sql Server 2000 (Windows 2000 Server 32 bit).
Now we are in the process to move all the databases from the Sql Server 2000 to a new Windows 2008 Server R2 Enterprise (64bit).
The new server has been already installed and doesn't have the same name of the Sql Server 2000.
We would like to upgrade all the Sharepoint 2007 database to the RDBMS so that we can dismiss the old, slow Sql server 2000.
Has anyone tried to do something similar?
You should do the following steps:
Backup all content and configuration databases. Backup your SSP databases.
Prepare content databases for moving.
Delete all the content databases.
Stop the SharePoint Farm by stopping a Timer, Tracing, Administration service
Copy mdf files of an old config database to a new SQL server
Attach SharePoint_Config database on a new server from copied mdf files.
Run stsadm -o renameserver -oldservername OLDSERVER -newservername NEWSERVER
Start all the SharePoint services stopped in 4.
Copy mdf files of content databases to a new server and attach these databases.
Attach content databases.
Add a content databases from a new SQL to SharePoint with stsadm or Central Administration
Restore an SSP databases
Create a new SSP using Restore command from an SSP database on a new SQL server.
Delete an old SSP.

Resources