How to connect to a SQL Server database through a local network

want to connect to the database on another PC connected via a local network. I can use db sql server with a string like C: \ Users ... but I can’t connect using a string like (\\ Server \ c \ user ...) I tried moving the db file to My Documents, all still I get this error.

The following error message appears: An attempt to connect the auto-name database for the file (\\ SERVER \ Users \ Jeswills \ Documents \ TBSDB.mdf) failed. A database with the same name exists or the specified file cannot be opened or is located on the UNC shared folder

I hope I asked the question correctly

+6
source share
2 answers

Since the database does not support the parameters '\ SERVER \ c ...', I had to attach the database after turning on the TCP / IP and SQL browser, I had to create a login through the security system and add it to the attached database file, since authentication should being SQL is not windows. And I also gave account read / write privileges. Then, in the child system, I confirmed the connection to the account via SSMS with the connection to the SERVER server (which is the name of the remote computer).

Note. You should be able to scan remote systems and SQL Server Express R2. I tried with SQL Server Express but did not get the head road. www.connectionstrings.com/sql-server-2008 for an additional connection string

Then I used this connection string for remote connection, making integrated protection and user instance = false, unlike the one I connected locally.

Data Source=SERVER\SQLEXPRESS,1433;Database=DATABASEFILE.MDF;Integrated Security=False;Network Library=dbmssocn;Connect Timeout=30;User Instance=False;user='USERNAME';password='PASSWORD' 
+4
source

Not sure what exactly you are trying to do here, but I think this is one of these two.

Option 1 Attach the database stored on the remote shared drive to the local SQL Server

Note that this is only possible in SQL Server 2008 R2. If you are using SQL Server 2008, this is not an option.

Check it out for more details.

http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-shared-drive.aspx

Option 2: Connect to a remote instance of SQL Server from the local computer

If this database is already attached to an instance of SQL Server that runs on the same computer, it is much better to simply connect to this instance from SSMS than to try to connect the database from remote storage.

To do this, you need to enable TCP / IP in SQL Server Configuration Manager. Its network configuration is SQL Server node. Make sure you enable TCP / IP and also configure the inclusion of an IP address for listening (this applies to TCP / IP properties).

In addition, you want to enable remote connections on the remote instance. This is done from SSMS -> instance properties -> Connection tab

When this is done, you will be able to connect to the remote instance from the local SSMS by entering the IPaddress / instance name. For example, 192.168.0.125/{instance_name} or only the IP address if this is the default instance.

+4
source

Source: https://habr.com/ru/post/955142/


All Articles