running program in computers without sql server - sql-server

Is it possible to run a program in which a SQL Server database has been used in other computers where "SQL Server" has not been install?

Certainly, you'd change the connection string to connect to a remote server like this:
Server=RemoteServerName;Database=DatabaseName;...
and in fact, that's the most common production configuration. A shared database amongst multiple users.

The answer is YES. The only thing you need to do is to point where the Microsoft SQL Server is placed. Of course, you need to configure the server to accept remote connections and that the client you're tring to connect has internet access.
Configure SQL Server to accept remote connections
Guessing that you use c#...
Connection strings for c#

Related

Cannot connect Access to SQL Server Linked Tables - error message loggingin

I have a client for which I am setting up a new SQL Server Express and (on a different computer) connecting their Access front end to that SQL Server. I created an account on SQL Server, changed authentication to SQL Server. I am able to log on to that account with no issues locally (through SQL Server Management Studio) on the server itself, but when I go back to the client machine and try to create either an ODBC connection or connect directly in Linked Table manager, I get the error below. Looking at the error log in SQL Server I can see no failed logins. In Access and/or ODBC I use Servername\SQLEXPRESS, choose SQL authentication and type in the username/password that I created. But it's still being stubborn.
I'm kind of at my wits end with this one. I checked to make sure that login is enabled, that the created database is mapped to this user, but I'm out of answers. Anyone have any ideas? I'm sure it's something really stupid that I'm overlooking, I've used SQL Server for a long time but I'm not an experienced DB Administrator I'm sure it's something really simple I'm overlooking, but I've done this hundreds of times before. And Windows Authentication won't work because it's on a different computer.
To connect to a named instance on SQL Server Express with Servername\SQLEXPRESS, you need:
SQL Server Browser service running,
and its UDP port 1434 open in the firewall.
https://learn.microsoft.com/en-us/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access
SQL Server Browser service
UDP port 1434
The SQL Server Browser service listens for incoming connections to a named instance and provides the client the TCP port number that corresponds to that named instance.
The fixed TCP port for your instance open in the firewall.
You set this in SQL Server Configuration Manager
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-server-to-listen-on-a-specific-tcp-port
This looks more like a network setting rather than server issue.
Check if all necessary permissions, configuration and settings on your machine running the server are OK to accept external connections.
Usually its the server that is rejecting the connection for security reasons.

SQL Server 2008 R2 First-Time Connection Issues

We've been experiencing a strange issue with SQL 2008 R2 (10.50.1600) installed as a named instance. In order for any external clients to connect, we have a certain procedure we have to follow, but should not have to. Now I did in fact open the TCP/IP and Named Pipes protocols on the SQL server and restarted it, this isn't the problem. We're on an Active Directory Domain (running from Server 2003). The problem exists no matter what OS the server or client is (XP, 2003, 2008, Vista, 7, 64bit, 32bit, etc.). The problem also persists from anything which can connect, for example, SQL Management Studio, ADO (from our applications), etc.
The problem is that before any client can connect to this server, each client machine must first connect to this server through ODBC (and we don't use ODBC). Any attempt to connect to a 10.5 SQL server before doing this results in "Server does not exist or access denied". But once we can connect in the ODBC (through Named Pipes), then everything else starts to work. The same issue occurs both when using the Computer Name and IP Address. In fact, if we want to connect with computer name \ instance name, then we have to do so first in the ODBC, and then if we want to connect via the IP address \ instance name, then we have to do the same also for that.
We've been having to do this on every single client computer. Again, once the ODBC is able to connect to this SQL server through Named Pipes, then all future attempts from that client work.
What could be causing this to occur? How to avoid it? I should not have to do this "ODBC Trick" as we've been calling it. I've never had this issue on any other version of SQL.
The issue might be related to the SQL Browser service. Each sql instance will have a different port number - try connecting from the client as IP Address,Port (e.g. 123.123.123.1,1433) - this will exclude DNS and Browser from the equation
Edit: now knowing that it is browser related, try see why clients can't access SQL Browser (usually Port 1434). Service not started? Possibly firewall blocking?
Microsoft have tied down everything security wise now by default, so any new configuration now generally requires quite a bit of detailed security planning, policy configuration, permissions etc. Welcome to the age of non-trust ;)
You could easily test your connection by creating a simple file. Follow the steps here at "How to test an SQL Server connection": http://teusje.wordpress.com/2012/02/21/how-to-test-an-sql-server-connection/

Invalid Key for attachdbfilename

I am using SQL Server DB. The connection string is
Data Source=office1\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbSQLTest.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True
On local computer it is fine. On the network computer, it gives
"Invalid Key for attachdbfilename"
I do not want to make server client application. My purpose to use Sql server DB is to run my application on 3-4 computer simultaneously. I just make shortcut from my main computer to the network computers.
The reason why I donot attach with server instance is that it is difficult for the users to attach DBs with server and then manage SSMS.
Please advise
Thanks
Furqan
AttachDbFilename is used with local database. If you have remote database then the connection string will be different. Have a look at article - How to configure SQL Server 2005 to allow remote connections.
I'm not sure I am understanding you correctly, but you can't simultaneously attach the same MDF on a network drive by several concurrent users (like you can do with MS Access).
Rather just install SQL Express on a central computer and open it up for remote TCIP/IP access, and change the connection string to an IP / instance one.

connect sql server 2005/2008 over internet

How do I connect to SQL Server 2005/2008 using Management Studio or other desktop application over the internet?
Check out WCF Data Services:
http://msdn.microsoft.com/en-us/data/bb931106.aspx
That way, you don't have to totally expose your database server out to the internet, but you get fine grained control over what gets exposed and who (which type of user) can see or modify what.
Marc
I finally solved this by:
Changing default SQL Port to 8080 from 1433 (our ISP was blocking)
Turning off Windows Firewall on the server. I know this is not a long term solution, but at least I was able to pinpoint the problem. I had set two inbound firewall rules to allow port 8080 and SSMS program, on the server. I created an outbound firewall rule on the client for SSMS (but don't think this mad a difference).
I had to change all apps to use the new port instead of the default port. I had to configure our router to handle the new port 8080 and forward to the database server.
I will modify the Windows Firewall settings to see what was blocking SSMS.
DB Server: Windows 7 Pro 64bit 24 GB RAM
If you put 'your' SQL server (any brand, I'm not bashing) on the internet ... it won't be yours for long, unless you add some rather effective security measures ...
I suggest you look into VPN.
To be able to access your database over the internet, you will need to make sure that the server that hosts the database is accessible over the internet and the port that the database instance uses is open on that machine. You will also need to allow remote connections using the SQL Server Configuration Tool.
For Management Studio access I would recommend rather than opening the server to the outside to use a VPN solution that allows you to create a secure connection to the server and from there you can use the server name or IP to connect as if your machine is part of that network.
For the desktop application I would recommend looking into having the data be consumed through a web service or WCF rather than needing to have a direct connection to the database over the internet.
Hope this helps.
Firstly, if we put security consideration on the side, you have to configure SQL server (sql surface area configuration) to accept traffic, then you have to open proper ports on you server and allow inbound traffic thru to your router to the SQL server.
When you open sql server management studio in connect to server window and at the server name type the IP of your server and enter your username and password.
correct format : IP\InstanceName
you should have a user on target database.

MS SQL ping external server

Is there a 'nice' way to check whether an network host is up
making use of 'plain' SQL? I thought of some MS-SQL specific
command or maybe some getting the return value from a ping script
on the server itself.
Does anyone has an idea on this?
There's two possible ways to take your answer:
1. you want to know if a SQL server is running on an arbitrary host
2. You want to ping an arbitrary host from a SQL server using some query.
you could use dariom's answer.
1a. if you want to query one SQL server from another, you're better off using the "Linked Servers" functionality of SQL Server.
You can use the master.dbo.xp_cmdshell stored procedure to execute PING, which then returns the results as text rows and a status code.
EXEC master.dbo.xp_cmdshell 'ping 192.168.1.1'
I'll assume you mean "plain" SQL and not "palin" :-)
If you're trying to see if SQL is running on a host you could try and connect to the SQL Browser Service by using the SSRP (SQL Server Resolution Protocol) (but this needs to be installed and running on the server).
You could try a "best guess" approach and make a TCP connection to port 1433 (the default port SQL Server's Database Engine). If the port is open, it might be that a SQL Server is listening - you could then try and connect to SQL Server and execute a command (like SELECT ##VERSION or something specific to your application). The problems with this approach:
SQL Server Database Engine can be configured to use a non-standard TCP port.
SQL Server might not even be using TCP - you'd have to connect using named pipes (I'm not sure how that's done).
Some other service could be configured to use TCP port 1433. It doesn't mean that SQL Server is listening.
If port 1433 is open and used by SQL Server, you'll need to provide credentials to connect to it and execute commands.
Essentially, the best guess approach will only really work with SQL Servers under your control.

Resources