Two SQL Server instances with the same name? - sql-server

I'm not sure how I ended up with this situation: I seem to have two SQL Server instances with the same name, in one machine.
Screenshot here
When I connect through SQL Management Studio I have access to the database of my application, but it is empty, tables have no rows.
However when my application connects through the next connection string it has all the rows it had inserted, I mean, the application works fine.
Data Source=DESKTOP-D5BH4BP;Initial Catalog=AppDB;User ID=AppUsr;Password=pass;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
So I guess each instance points to its own files.
The question is: How can I get rid of the empty instance??

You cannot have two instances with the same name on SQL Server, it is not possible at all.
The drop down you have shared in your screenshot is only showing the server names you have connected to in past using SSMS, you can type anything there but whether that server exists or not is something different.
To get rid of these names from the drop down list, just select the name and press Delete key.

Click on < Browse for more...> and you'll see the single instance
If you want to remove the duplicate entry from the drop down, just mouse hover on the entry and hit delete on the keyboard.

Related

MS Access 2016 crashes on a certain linked SQL Server table

I imported MS Access tables into a SQL Server 2012 database. In MS Access, when I change the link to the SQL Server table, the database does not open (stops responding and closes).
I change them back to the Access tables and they open fine. I then change the links one table at a time and re-open. It isn't until I get to one table (that only has an int Identity and a nvarchar(20) column) that it stops opening.
What is going on? When it is linked to the SQL Server table (and I open the MS Access database using the shift key) I am able to open the table and add/edit records. It seems to just not like opening the initial form that uses this table.
I even deleted the SQL Server table and built it from scratch and it still crashes.
It is important for us to know what's going on when you don't prevent execution by pressing the shift key.
Please show us the code being executed.
In general, it is always worth a try to decompile/compact the database in case of strange behavior: "c:\Program Files\Microsoft Office\Office16\MSACCESS.EXE" "c:\test\YourDatabase.accdb" /decompile /compact
Remark: The path to the exe depends on the Access version/platform you installed.
So for Access 2016 it could be one of these (64bit/32bit):
c:\Program Files\Microsoft Office\Office16\MSACCESS.EXE
c:\Program Files (x86)\Microsoft Office\Office16\MSACCESS.EXE
In addition, in such strange situations, it is also worth making sure that Microsoft Access is fully patched. The search and installation of updates should be considered.
what is the name of the table? (access and sql have different reserved words) and if you use one of them, you may be able to create a table but never access it.
If the table name has spaces in it, Access is generally ok, but sql is really not ok.
Simple solution: If you have spaces in the name - remove them and relink.
As most reserved words are single words - if you use a single word as the table name, change it to two words joined together.

Re-linking Tables in Access Database

First of all - my VB skills are almost non-existent so any suggestion/ideas should be a little more elaborate if possible. Here is the problem I am facing -
We have linked database tables and queries in Ms Access 2010. Now a copy of the database has been created on a new SQL server. So I want to re-link the tables so that access points to the tables on the new SQL server. Right now, all the tables are corresponding to the database on the old server. Here is what I have tried -
Open XYD_Outreach_Dev.accdb on the network (this is the dev version of access that we use)
Form a new ODBC connection which creates a new_sql_server.dsn file corresponding to the new SQL server (2012)
Go to External Data -> ODBC Database -> Link to the data source by creating......
Link to a table say - tblAbriContacts
This creates a new linked table dbotblAbriContacts
I rename it to tblAbriContacts at which point Access asks me -> table already exists. Do you want to replace it? I click yes and the table gets replaced
I hit the save button, close the application and restart it. The tblAbriContacts is pointing to the old database again
What could be the issue? Please note that I have to do this for all the database, lookup and junction tables.
Do I have to change some connection string which the access points to as soon as it is launched?
If I try the Linked table manager, nothing happens, it says "All selected tables were successfully refreshed". But nothing happens. I guess that's because the tables haven't been moved from the old database. A new copy of everything has been created on the new server.
Please help me out with this. My work is stuck because of this reason.
Can you please check if there is a module or other vba file created and file's on_load event has some code which to assign the connection string for all objects (tables and SPs) and refreshes it every time you restart the application.
If you see the connection string there, you might need to replace it with the new one.

Command(s) completed successfully but... the tables are not created

I backed up my database table's and entire schema into .sql script using Visual Studio's Database Publishing Wizard.
I then tried to re-create those tables on another PC, not before re-creating the database itself, with the same exact name and everything (using a script that I created via SSMS's Script Database as).
I then open that tables .sql file using SSMS and execute it.
SSMS reports:
Command(s) completed successfully
But examining Object Explorer reveals that no tables were created.
Why is this happening?
What have I missed?
I've just been having the exact same problem symptoms also using Visual Studio's Database Publishing Wizard, - but with a slightly different cause / fix.
Even though SQL Server Management Studio says it is connected to the correct database (in the drop down in the ribbon, and in the status bar of the window), it wasn't actually connected to anything.
To identify and fix either:
SELECT DB_NAME() AS DataBaseName
If you get
master
(or any other unexpected database name) as the result, then you are connected to the wrong database and should select the correct DB from the dropdown. This was the cause of your problem.
If you get
Command(s) completed successfully
then somehow you aren't connected at all - this happened to me.
To fix, click the "change connection" button to disconnect and reconnect.
Check whether you have selected database. Most of the times we execute query in Master db by mistake.
-- Mark as answered if this answer really answered your question
Check if you are running "Execute" or jut Parsing the code. It was a late night, I was tired, and kept running a query to create a table, successfully, but no new table. The next day with a clear mind i noticed that i was not actually running the query, i was parsing it.

How to remove cached server names from the Connect to Server dialog?

Or, to put it another way, where is SqlStudio.bin for SQL Server 2012? It doesn't seem to be in the place that would be expected by looking at this other SO question.
As of SQL Server 2012 you no longer have to go through the hassle of deleting the bin file (which causes other side effects). You should be able to press the Delete key within the MRU list of the Server Name dropdown in the Connect to Server dialog. This is documented in this Connect item and this blog post.
To be clear, since a couple of people seemed to have trouble with this for months: You need to click on the Server name: dropdown, and down-arrow or hover with your mouse until the server you want to remove is selected, and then press Delete. In this screen shot, I'm going to press Delete now, and it will remove the server ADMIN:SHELDON\SQL2014 from my MRU list. Note that because I merely hovered with my mouse, this is not even the server that is showing in the Server name: text box.
Note that if you have multiple entries for a single server name (e.g. one with Windows and one with SQL Auth), you won't be able to tell which one you're deleting.
Found it!
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
So the answer is as before: delete the file, or use some nifty PowerShell magic to edit it.
As for SQL Server Management Studio v18 it appears this file is now XML and you can edit it directly:
%APPDATA%\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml
If you want to remove particular account or update password on Windows 10 then you can go to Windows Credentials in Credential Manager and update or remove related entry:
Control Panel >> Credential Manager >> Windows Credentials >> Microsoft:SSMS
This is the best way to clear these server names from the list.
Open the(SSMS) version. Mine is 18.
You should be right where you can see the server name dropdown list.
If not, you will open the Connect to Server dialog located in the File menu bar
Click on the Server Name field dropdown list.
"Hover over" (very important) the items you want to remove.
Pressing the delete (DEL) key on your keyboard should do the trick.
You're welcome

adding a new column in SQL SERVER but it is not showing up in access

access is the front end and sql server 2008 is the backend
i am opening the specific table in access. i have no problem editing data in this table using sql server and then displaying the changes in access; however, when i add a new field in sql server, the changes are not reflected in access.
i am opening the table as a datasheet and it is not showing the new field that i added in access. ive opened and closed the file and still doesn't work
anyone know what's going on here?
You might need to refresh the SQL Server table in Access using Linked Table Manager.
I cannot add comment but I like to add...
since it irritates me.
It is the same story not only in MS Access, it is the same in SSMS (MS SQL Server Management Studio, even from the latest MS SQL Server 2008 R2) with its own "native" mdf databases and tables from it.
If to change the content of a table through another window / tab or instance of SSMS (by TSQL, or by interactive editing) then the content shown in already opened for interactive editing table is not updated, though it is updated by non-documented Ctrl+R.
And it is not available in GUI of SSMS (no menu entry, no button, etc.)!!!
Any browser/webapp can be easily configured to update the content but not MS desktop IDE GUI!!!
But if to ALTER TABLE, for ex., to add a column, then already opened tab with table (SSMS) cannot reflect the changes (cannot show altered table, for ex., with added column) even by pressing Ctrl+R.
It is necessary to close tab (window) with table and reopen it
(right-clicking on table in SSMS ObjectExplorer --> Edit tio 200 rows)!!!
I remeber I opened a bug in Microsoft Connect feedback on it and it was closed as this was a feature "by design"!
Still IMHO it is a bug and requires brute force (/ugly GUI actions) to bypass it
This SO Q&A seems to cover similar territory.

Resources