How to connect to sql server database via LAN - sql

want to connect to a database on another PC connected via LAN. I am able to use the sql server db with string like C:\Users... but i cannot connect using string like (\\Server\c\user...) I tried to move the db file to My Documents, still i get this error.
I get the following error message: An attempt to attach an auto-names database for file (\\SERVER\Users\Jeswills\Documents\TBSDB.mdf) failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
I hope i asked the question correctly

As database does not support the '\SERVER\c...' parameters, i had to attach the database, after enabling TCP/IP and SQL Browser, i had to create a login through security and add it to the attached database file because authentication must be SQL not windows. And i also gave read/write privileges to the account. Then on the child system, i confirmed connection to the account through SSMS with the login connecting to SERVER (which is the remote computer's name).
Note: you must be able to ping the remote systems and SQL Server Express R2 installed. I tried with SQL Server Express but did not get a head way. www.connectionstrings.com/sql-server-2008 for more connection string
Then i used this connection string to connect remotely, making integrated security and user instance = false unlike if i were connecting 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'

Not sure what specifically you’re trying to do here but I guess it’s one of these two.
Option 1
Attach database stored on remote shared drive to a local SQL Server
Note that this is only possible starting in SQL Server 2008 R2. If you’re running SQL Server 2008 this is not an option.
Check this 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 remote SQL Server instance from local computer
If that database is already attached to SQL Server instance that runs on the same machine then it’s much better to just connect to that instance from SSMS than trying to attach database from remote storage.
To do this you need to enable TCP/IP protocol in SQL Server Configuration Manager. It’s under SQL Server Network configuration node. Make sure you enable TCP/IP and also set enable the IP address for listening (this is under TCP/IP properties).
Apart from this you’ll want to enable remote connections on your remote instance. This is done from SSMS -> instance properties -> Connection tab
When this is done you should be able to connect to remote instance from local SSMS by typing in IPaddress/instance name. For example 192.168.0.125/{instance_name} or only IP address if this is default instance.

Related

Connecting to a SQL Server with SQL Server Managament Studio

I have looked everywhere on Stack Overflow and I have not found an answer that closely compares to my scenario, so please bear with me.
The issue is I was recently given a development server at work and I have to migrate my current project (which I have on SQL Server Management Studio running on SQL Server Express) so that it is hosted on that server. I was just given the server name and authorized access to it. So I can connect to it through Remote Desktop Connection (RDC), but I am clueless as to where to go from here.
I have tried going in through RDC and opening Management Studio from there but when plugging in my server name and using Windows Authentication it doesn't let me in. And I can't use SQL Server Authentication because I'd have to be actually in to be able to create an SQL login.
How can I connect to this server through Management Studio?
The server is in the same network? In the management studio, in server name, you can put a IP address or computer name.
Do you know if SQL is even installed on the server you are tasked to deploy to? You are able to "connect" to SQL Express locally because the instance is installed on your local machine. You will need an instance of SQL installed on the remote machine to be able to use SSMS to connect to the remote instance.
If you are attempting to connect to an already created DB that you have been using the credentials are the same, if you know the address and you have the ports opened on your computer to allow the connection. If you are going to start a new DB on the server, then you will have to connect via AD credentials IF your admin has given you the proper access. I personally suggest using AD credentials to create connections, it's just a lot more secure.
If you are trying to connect to the local db, then it should be on the drop down list on the log in screen.
You are going to have to talk with your admin who set it up if you are still having problems.
You might have to Enter your Server Details in the Hosts File on the Current Application Server
For Accessing Hosts File,
Go to Run and type drivers and Hit Enter. Go to the etc Folder and you will see hosts file in the Folder.
At the End of the File Enter the Server IP And Server Name
Save the file and try Logging into the Server Management Studio again
Hopefull, this would help

SQL Server Express - Connect from remote machine

I have two Win 7 64 bit machines.
On the first one I have installed SQL Server 2008 R2 Express and have no trouble connecting via Management Studio with Windows Auth and also via SQL Auth with a user I set up on the database.
On the second machine I am trying to connect to the database on machine 1 using Management Studio. I'm trying SQL Auth. I therefore obviously also can't connect to it via connection string in my .NET Code
I can ping the first machine from the second.
Things I have tried include the following:
On the machine the database is installed make sure the firewall is allowing connection on Port 1433
Made sure SQL Server service is running
Made sure SQL Server Browser service is running
Created an exception for sqlbrowser.exe in the firewall
Enabled TCP/IP Protocol through SQL Configuration manager
Allowed Remote connections in SQL Server Management Studio
The error I get is:
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
This is the connection string I use in code
Data Source=xxx.xxx.xxx.xxx\sqlexpress;Initial Catalog=dbName;User Id=myUser;Password=myPassword;
This can be caused by a number of reasons but I'm glad my suggestion about checking firewall ports (rather than just allowing a one-way exception for SQL Browser) led you to the answer: the firewall wasn't allowing the correct port # through.
If i remember correctly SQL Server disables remote connections by default.
Please check whether remote connections are enabled and enable them if not:
RMB on Server in Management Studio Object Explorer -> Properties -> Connections -> Allow remote connections...

Can't get SQL server name

I'm trying to add new data source via the data source configuration wizard. I'm using Microsoft SQL Server as data source and .NET framework Data Provider for SQL Server as data provider. In the next window where I have to choose the server name, the list is empty. So I thought one of the SQL services are not working, I opened services.msc and there were 6 services, from which only SQL services vss writer was enabled. I enabled all of them (SQL Server, SQL Server agent, SQL Server browser, SQL Server Active Directory Helper) but the list still is empty. What should I do?
The SQL Browser service is the one used to allow other machines to discover the SQL server's existence on the network, though this requires TCP/IP or Named Pipes to be enabled in the SQL configuration, so check that too.
Also check your firewall isn't blocking the UDP port 1434 (and TCP port 1433 for that matter) [note, these are the default ports; they can be changed in the configuration).
The problem here might be your Database might not have permission over network..
Just try to connect by using Sql Authentication using sa account and password.. This should help you.
The other reason might be if you are using Visual studio 2010 it wont show database from Sql Server 2000
Accept or Vote up if it works for you.

SQL Server fails to connect to database on client

I have installed SQL Server 2008 R2 Express on a Windows Server 2008 R2 machine, and now when I want to open that database using SQL Server Management Studio on the client machine it fails to open.
But the database opens normally on the server.
The owner of the database is sa and on client I am logged in with windows authentication.
How to resolve this error??
the server priciple smtech/prabhu is not able to access the database
the user is of client under the server domain
I suggest making sure that the account you are trying to connect with actually has access.
Log onto the server, open up management studio, look in object explorer. There should be a Security folder icon in the treeview, Expand that and the Logins folder.
If the user you are trying to connect with isnt present you may need to add it.
Other than this instead of connecting with windows authentication maybe try connect with SQL Server Authentication as the SA user?
Is both Client and DB sever are on SAME domain ?? If not, then I think Windows Authentication will not work for you.
(As already suggested in above answer) create a SQL Login try with to connect DB from Client using that Login.
If both machine are on same domain and still you are not able to connect server, then few things you can check,
Can your client actually "see" this server over network ??
Most common reason is firewall. By default SQL Server communicates from port 1433 and 1434. Try to see if this MSDN link helps
Make sure that your SQL Server instance is configured to communicate using TCP/IP. This can be configured from SQL Server Configuration Manager.

How to connect database over local area network SQL Server 2008

I want to connect my db on SQL Server 2008 over local area network I want to put it on one computer on the LAN so any computer on the network can access it what should I do please give me correct steps
In a Client-Server scenario, you will have the SQL Server installed on your server machine.
Clients will be the computers accessing that SQL Server using a client software (can be SQL Server Management Studio, web/forms application, Excel worksheet, etc).
Each of the client will provide you a way of making a connection to the SQL Server Instance running on the server. From server you will need IP Address or Servername along with SQL Server Instance name. They both combined form host name.
Data Source = ServerName\InstanceName
Note: Instance name not required for default instance.
User name: You need to add user from domain or a sql server authenticated user under security tab (SSMS) on the SQL Server.
Password: Corresponding password.
Note: Once you add a user to SQL Server Instance, do not forget to attach the user to databases you want the user to access and provide appropriate role(s).
Install SQL Server 2008 on one machine on your LAN (let's call it SQLServer)
Connect that machine to the LAN (network cable)
You're done.
Now, all other computers can connect to that SQL Server machine by its name in the connection string - in .NET, that would look like:
server=SQLServer;database=YourDatabase;User ID=YourUser;Pwd=top$Secret