0

When executing integration tests, I'm using a connection string to connect to the database. I know there is a default notation for connecting to the default server instance in a connection string:

data source=.;initial catalog=[database name];integrated security=SSPI;

Unfortunately the database is currently not installed on the default server and due to compatibility issues I am unable to change to the default server. Now for all my tests, I will have to assign the sever name like so:

data source=[My Server name] ;initial catalog=[database name];integrated security=SSPI;

Since the solution is shared, I can't check this configuration in, and I'll have to do a lot of manual maintenance for this.

Is there any way I can change the default SQL Server for my PC, so that I can use the connection string as shown in the first example?

EDIT:

I was able to successfully use the following connection string:

data source=.\SQLEXPRESS;initial catalog=[database name];integrated security=SSPI;

EDIT 2:

I was able to resolve my issue by this awnser

martijn
  • 1,417
  • 1
  • 16
  • 26

3 Answers3

1

I managed to resolve the issue by following the steps in this post: https://stackoverflow.com/a/11921896/1829773

martijn
  • 1,417
  • 1
  • 16
  • 26
0

To change the default server, do:

sp_dropserver <old_name>;  
GO  
sp_addserver <new_name>, local;  
GO  
Samar Rizvi
  • 423
  • 5
  • 18
0

you can try this :

  sp_dropserver 'your server name'>;  
  GO  
  sp_addserver '.', local;  
  GO  

You can change your connection string to :

data source=.;initial catalog=[database name];integrated security=True;

This will not disturb other developpers.

Coskun Ozogul
  • 2,389
  • 1
  • 20
  • 32
  • This did change the name,but i still can't connect to it using the default connection string – martijn Dec 08 '17 at 11:42
  • What is the error ? may be SSPI ? Can you share the error message ? – Coskun Ozogul Dec 08 '17 at 12:35
  • There is no error message. I Can update the name, but the connection string still fails. When i run sp_helpserver i see the name and network name have been changed – martijn Dec 08 '17 at 13:05
  • Changing the integrated security from SSPI to TRUE didn't change how it worked. I still can't connect when I use the . as datasource, and I can connect when I use the server name. – martijn Dec 08 '17 at 13:15
  • I want to say, what is the error when you try to connect. Server not found ? – Coskun Ozogul Dec 08 '17 at 13:44
  • the error i got: System.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ----> System.ComponentModel.Win32Exception : The network path was not found – martijn Dec 08 '17 at 16:30
  • I saw that you found the solution. Happy for you. – Coskun Ozogul Dec 08 '17 at 20:04