Many of us use systems where multiple SQL Servers need to talk to each other over the network. But nobody's network is perfect. Sometimes the linked server is down, sometimes the link between them is down, sometimes another user changed the login credentials. Whatever the case, you need to be prepared in the event that the server is not available.
toshiba
Computer memory is the quickest, cheapest, and easiest way to improve the performance of your system. Find RAM memory upgrades for desktops, laptops, servers, and printers all backed by a lifetime warranty and guaranteed compatible with your computer. Shipping is an everyday low price of $1.99! Computer Memory Outlet sells memory compatible with all leading computer manufacturers like Dell, Apple, Compaq, HP, Sony, IBM, Lenovo, and many more.”
laptop battery
In SQL Server 2000, you will see this:
"Computer industry analysts estimate that some 60 percent of all corporate data exists only on desktop and laptop computers, " said Walter Scott, CEO of Acronis. "Incorporating Acronis True Image with New Mexico Software backup server is the ideal solution to capture that corporate data and ensure that it is not lost. While traditional server backups are effective for protecting server data, every company should have a combination of server and workstation backup plans."
thinkpad
You acknowledge and agree that You are solely responsible for all acts, omissions and use under and charges incurred with Your account or password or in connection with the server or any of Your server content displayed, linked, transmitted through or stored on the server. (i) prevent any loss or damage to Your server content; (ii) maintain independent archival and backup copies of Your server content; (iii) ensure the security, confidentiality and integrity of Your server content transmitted through or stored on Go Daddy servers; and (iv) ensure the confidentiality of Your password.
microsoft
| Server: Msg 17, Level 16, State 1, Line 1
Unrecognized method names in the server configuration files will result in the server logging an error message and failing to start. In .htaccess files, unknown methods will cause the server to log an error to its error log and return an 'Internal Server Error' page to the client. laptop computers
SQL Server does not exist or access denied. |
And then, of course, we have the Standalone Server product, which is called Acronis True Image Server for Windows or Linux and that will manage a single standalone server. What type of computers can we back up, because in a medium to a large sized, even some small sized businesses, who knows what kind of computers they have They may have laptops, they may have desktops, they may just have anything and everything
laptop computer
In SQL Server 2005, you get a much more useful error message:
desktop computer
notebooks
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "Login timeout expired". lenovo
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.". hard drive
Msg 2, Level 16, State 1, Line 0 travelstar
Named Pipes Provider: Could not open a connection to SQL Server [2]. gateway
laptop parts
--or software
hard drives
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "Login timeout expired". electronics
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.". canon
Msg 11001, Level 16, State 1, Line 0 desktop pc
TCP Provider: No such host is known. desktop computers
think pad
--or repair
data recovery
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "Login timeout expired". cisco
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.". keyboard
Msg 10060, Level 16, State 1, Line 0 monitor
TCP Provider: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. desktop
infosys
--or refurbished laptops
wipro
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "Unable to complete login process due to delay in opening server connection". lap top
Msg 7303, Level 16, State 1, Line 1 refurbished
Cannot initialize the data source object of OLE DB provider "SQLNCLI" for linked server "linked_server_name". memory
intel
--or as400
averatec
Msg 10054, Level 20, State 0, Line 0 hardware
A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) dual xeon
storage
--or seagate
computer sales
Msg 233, Level 20, State 0, Line 0 computer hardware
A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) |
printers
Most of these errors could be due to a misconfigured linked server, but they could also be due to network or hardware issues. Of course, these errors abort the entire batch, so whether or not the rest of your code requires the remote server to be active, it still terminates. In SQL Server 2000, you cannot trap for this type of error using @@ERROR, ROLLBACK, etc.
technology
mainframe
There are some workarounds, thankfully.
samsung
computer repair
PING: the knee-jerk reaction used computers
network
A very common suggestion to avoid this pitfall is to use PING from a command line; for example:
digital cameras
desktops
CREATE TABLE #foo cognos
( hosting
pingResult SYSNAME NULL netfinity
); internet
cheap computer
INSERT #foo digital camera
EXEC master..xp<>_cmdshell printer
'ping linked_server_name'; xseries
maxtor
IF EXISTS data storage
( hitachi
SELECT 1 rational
FROM #foo websphere
WHERE pingResult LIKE '%TTL%' battery
) it support
BEGIN western digital
PRINT 'Feel free to use linked server.'; music
END networks
ELSE toner
BEGIN cheap laptops
PRINT 'Linked server not available.'; wholesale
END brother
netvista
DROP TABLE #foo; |
camera
There are several problems with this approach:
networking
- In SQL Server 2005, xp<>_cmdshell is disabled by default. You will get the following error: sharp
cheap
Msg 15281, Level 16, State 1, Procedure xp<>_cmdshell, Line 1 windows
SQL Server blocked access to procedure 'sys.xp<>_cmdshell' of component 'xp<>_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp<>_cmdshell' by using sp_configure. For more information about enabling 'xp<>_cmdshell', see "Surface Area Configuration" in SQL Server Books Online. |
monitors
(See SQL 2005 Article #29 for more details.) linux
computer support
When you get past that, you might see the following: used laptops
cameras
OLE DB provider "SQLNCLI" for linked server "linked_server_name" returned message "Unable to complete login process due to delay in opening server connection". scanners
Msg 7303, Level 16, State 1, Line 1 panasonic
Cannot initialize the data source object of OLE DB provider "SQLNCLI" for linked server "linked_server_name". |
workstation
This one I have not resolved yetI am in the middle of configuring a brand new set of SQL Server 2005 machines, and the fact that they are virtual servers using VMWare might have something to do with it. I am finding that linked servers in 2005 only stay "initialized" for a short period of time, then become idle. At which case, they require some sort of "prodding" in order to be useful again. My workaround for now is to set up a scheduled job, that runs every minute, and runs a single one-row SELECT against each linked server. This is a hack workaround but for now is the only way I can keep the linked servers running reliably. I am hoping to get a more official answer from Microsoft... iseries
backup
- The linked server name might not be one that Windows understands. For example, it could be an alias for the actual network name or IP address, in which case the alias name might not be understood by WIndows or, even worse, the alias name might be used to maintain compatibility even though a server has been renamed. So, for all you know, you could be pinging the wrong box. information technology
routers
- Ping and other ICMP traffic may be blocked by any firewall or router between the caller and the callee. This is a very common scenario in servers or data centers exposed to the Internet (go ahead, try pinging www.microsoft.com). 180gxp
notebook battery
- Even if your ping request gets through and is successful, this does not necessarily mean that you will be able to communicate with SQL Server via the port SQL Server is listening on (1433/1434 by default). The port may be disabled, or blocked by software (e.g. ZoneAlarm) or even hardware (router or firewall). It also does not necessarily mean that the SQL Server instance you are trying to connect to is actually running. Nor does it guarantee that your linked server credentials are (still) valid.
A Better Approach security
lotus
A more reliable way to determine if a SQL Server is up is to actually try to connect to it. As opposed to calling it directly, you can capture any errors by shelling out to osql instead of querying the server directly (e.g. using four-part naming). Note however that this will take 10 seconds to timeout if the server cannot be reached.
virus
thinkpad t42
SET NOCOUNT ON; thinkpad 600
thinkpad 600e
CREATE TABLE #foo thinkpad 570
( thinkpad 600x
dbname SYSNAME NULL thinkpad 390x
); thinkpad a31
thinkpad x20
INSERT #foo bios update
EXEC master..xp<>_cmdshell laptops
'osql toshiba
-S<server_name>\<instance_name> laptop battery
-dMaster thinkpad
-U<user_name> microsoft
-P<password> laptop computers
-Q"SELECT Name FROM sysdatabases"'; laptop computer
desktop computer
IF EXISTS notebooks
( lenovo
SELECT 1 hard drive
FROM #foo travelstar
WHERE LTRIM(RTRIM(dbname)) = N'master' gateway
) laptop parts
BEGIN software
PRINT 'Feel free to use linked server.'; hard drives
END electronics
ELSE canon
BEGIN desktop pc
PRINT 'Linked server not available.'; desktop computers
END think pad
repair
DROP TABLE #foo; |
data recovery
In SQL Server 2005, first, you have to enable xp<>_cmdshell, otherwise you will see this error:
cisco
keyboard
Msg 15281, Level 16, State 1, Procedure xp<>_cmdshell, Line 1 monitor
SQL Server blocked access to procedure 'sys.xp<>_cmdshell' of component 'xp<>_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp<>_cmdshell' by using sp_configure. For more information about enabling 'xp<>_cmdshell', see "Surface Area Configuration" in SQL Server Books Online. desktop
|
infosys
To enable xp<>_cmdshell, run the following code:
refurbished laptops
wipro
USE master lap top
GO refurbished
EXEC sp_configure 'show advanced options', 1 memory
GO intel
RECONFIGURE WITH OVERRIDE as400
GO averatec
EXEC sp_configure 'xp<>_cmdshell', 1 hardware
GO dual xeon
RECONFIGURE WITH OVERRIDE storage
GO seagate
EXEC sp_configure 'show advanced options', 0 computer sales
GO |
computer hardware
A little more elaborate sample for SQL Server 2000 or SQL Server 2005 uses SQL-DMO. See usp_serverup.
printers
technology
In SQL Server 2005, you have some new options. You can use the new system procedure sp_testlinkedserver within the new TRY/CATCH construct:
mainframe
samsung
BEGIN TRY computer repair
EXEC sp_testlinkedserver N'linked_server_name'; used computers
END TRY network
BEGIN CATCH digital cameras
PRINT 'Linked Server not available'; desktops
ROLLBACK; cognos
RETURN; hosting
END CATCH netfinity
internet
-- continue with usage of linked server |
This will still raise warning messages, but it will at least let you get out of the batch on your own terms.