martijn
martijn

Reputation: 1469

Change default MSSQL datasource for connection string

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

Upvotes: 0

Views: 1033

Answers (3)

martijn
martijn

Reputation: 1469

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

Upvotes: 1

Coskun Ozogul
Coskun Ozogul

Reputation: 2469

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.

Upvotes: 0

Samar Rizvi
Samar Rizvi

Reputation: 433

To change the default server, do:

sp_dropserver <old_name>;  
GO  
sp_addserver <new_name>, local;  
GO  

Upvotes: 0

Related Questions