How to connect database over local area network SQL Server 2008 - sql

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

Related

Set up SQL Server to be accessible by all computers on a network via program manipulation

I am testing a SQL Server for my company as an on-site database for manufacturing data and records. I have the SQL Server on my laptop and have set up permissions and downloaded SQL Server Management Studio on other computers in the company and managed to connect via SQL Server authentication.
However, I can't get Windows Authentication to work. I also have a Visual Basic program that I can run on my laptop that will communicate with the SQL Server that is locally on my machine but that program will not work on other computers in the company because they can not connect to the SQL Server.
How do I set up SQL Server to allow for Windows authentication on any company computers running that program? I opened a port on my Windows firewall on the computer that has SQL Server installed, and it seems to work with SQL Server authentication.
The connection string I am using in my Visual Basic program is as follows:
Dim connstring As String = "Data Source = Server; integrated security = true"
I assume I need to change something in my logins folder in my SQL Server?
My desired result would be for any computer running this application to be allowed to communicate with SQL Server and be able to read and write data.
any computer running this application to be allowed to communicate with SQL Server
The normal configuration to enable this is:
1) The SQL Server must be running on a server joined to the domain.
2) The SQL Server is configured to use TCP/IP and listen on port 1433.
3) The other computers are also joined to the domain.
4) The users logged in on the other computers are added as Windows logins. in SQL Server, and mapped to users in the desired databases (can use groups instead of individual users).
See eg: How to add Active Directory user group as login in SQL Server

Connect to SQL Server in VM using local machine

I would like to connect SQl server DB in VM using my local sql server management studio.
What should I need for server name ?
Can I use my server Windows authentication for VM in my local ?
Create an empty text file on your VM and give it extension .udl
Doubleclick on it now you can set the properties easy from combobox
Adjust the properties and click on "test connection" until it works
Now open the file in notepad and there you see a complete connection string.
Note that for SQL Server authentication you need to configure the protocol in SQL Server Configuration Manager
When you are in Management studio on your local machine, you will need the hostname or IP address of the VM.
For Windows Authentication, you will need an account on the local domain that both your workstation and the database VM are connected to.
For SQL server authentication, you will need an account in the SQL Server instance.
In both cases, security will need to be configured and associated with your account.
Are you on a domain, or is this just a private server?
Use name of the VM where SQL server is running.
And yes, you can use Windows authentication. Depending on your domain settings.
This will help you How to: Create a SQL Server Login It is not much difference from SQL login.
And if you are in Administrators group on machine running SQL Server, then your login already should be included.
And if your machine with Management Studio and server with SQL Server are in different domains, then you will need to run Management Studio under different account
runas /netonly /user:domain\username "c:\path\ssms.exe"
See Connect to SQL Servers in another domain using Windows Authentication

How to connect to sql server database via LAN

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.

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 to another sql server database(server pc) in local area network

i m creating an application, inwhich client has to acces a database stored in a remote location connnected through a live ip. how can i connect simply with a database server placed in LAN. both using sql server 2005 express edition. please refer me or help me on this
Set in your connection string IP address of remote server.
E.g.
"Data source=192.168.0.13; Database=MyDb;User ID=my_user;password=12345"
where 192.168.0.13 is your remote server IP and MyDb is your database name.
Also, make sure to configure your SQL Server Express to allow remote connections! Those are disabled by default after installation.
Check out the SQL Server Surface Configuration tool (if I'm not mistaken) to configure these settings.
Marc
This not about programming. You have forward the port which Sql Server uses on modem.