Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Missing Linked Server

Author  Topic 

Artoo
Starting Member

16 Posts

Posted - 2008-04-15 : 05:37:42
Hi,

I have an issue with one of my production servers. I have a few production servers, and they all have the same objects. I do not want to create custom objects for each one, rather keep them all standard.

However, due to environment issues, I have one which does not have any linked servers.

I have a proc which queries either locally or across the linked server depending on the value of a switch. I want to install this proc on the server with no linked servers but it obviously fails.

I can guarantee the proc will never be called with the switch 'on' on that particular server. We still want to install this proc and call it with a switch of 0.

Please can somebody come up with something really clever.

The proc goes something like this:


CREATE PROC WhatEver @Switch int
AS
IF @Switch = 1
BEGIN
SELECT * FROM LinkedServer.Db.dbo.MyTable
END
ELSE BEGIN
SELECT * FROM dbo.MyTable
END


Thanks in advance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-15 : 05:44:47
Why it fails it you always call it with Switch of 0?
Go to Top of Page

Artoo
Starting Member

16 Posts

Posted - 2008-04-15 : 05:53:46
Firstly it fails when you try to install it.
Could not find server 'LinkedServer' in sys.servers.

Secondly if I create a linked server pointing to itself and delete this server after I install the proc, it fails when you run it even if the switch is 0.
Go to Top of Page
   

- Advertisement -