Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Linked servers


Linked servers

Author
Message
Tobar
Tobar
SSC Veteran
SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)

Group: General Forum Members
Points: 269 Visits: 758
I would like to create a linked server with the name "Production" that points to an IP address&port of an server instance. I want to do this so I can refer to [Production] in all my queries so that when the IP&Port of "Production" changes all the queries keep working. It looks like all I can do is create a linked server with the name IP address&port. This causes the head-ache of needing to update every query when the server changes. Am I missing something or is there no way to abstract a linked server?

<><
Livin' down on the cube farm. Left, left, then a right.
Orlando Colamatteo
Orlando Colamatteo
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8275 Visits: 14368
USE [master]
GO
EXEC sys.sp_addlinkedserver
@server = N'Production',
@srvproduct = N'',
@provider = N'SQLNCLI',
@datasrc = N'127.0.0.1,1713'; -- fix this up for your IP and port



Then you can drop and recreate it as needed:

USE [master]
GO
EXEC master.dbo.sp_dropserver
@server = N'Production',
@droplogins = 'droplogins';
GO



__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
ALZDBA
ALZDBA
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 6984 Visits: 8839
You could also just fix the port number of your production instance.

It shouldn't change that much, unless someone just didn't pay attention to the port number the installed the instance.
Must be a heck of an issue for your FW-admins too.

I'm always very wary when someone request a linked server definition.
Untangling issues on both involved servers ( or more, in case of join with extra linked server queries )
often takes way to long.

Another thing people often forget is the difference in maintenance windows for linked server involved instances.
Queries and apps not working because of linked server maintenance windows aren't considered an issue until they happen.

I hope you've got your environment under control.

Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution" :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
Tobar
Tobar
SSC Veteran
SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)

Group: General Forum Members
Points: 269 Visits: 758
Thanks to both of you.

Unfortunately I/we have virtually no control over the choices being made. :-(

<><
Livin' down on the cube farm. Left, left, then a right.
Tobar
Tobar
SSC Veteran
SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)

Group: General Forum Members
Points: 269 Visits: 758
Looking into to this more I do have a question:

So to add a linked server you use sp_addlinkedserver and to delete it you use sp_dropserver?

sp_addserver is unrelated?

Is it possible to alter a linked server, i.e. change what it points to, or do you just drop and create again?

<><
Livin' down on the cube farm. Left, left, then a right.
Orlando Colamatteo
Orlando Colamatteo
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8275 Visits: 14368
Tobar (4/10/2013)
Looking into to this more I do have a question:

So to add a linked server you use sp_addlinkedserver and to delete it you use sp_dropserver?

Not a great naming convention on someone's part, but yes.

sp_addserver is unrelated?

You won't need to call sp_addserver directly for Linked Server creation. sys.sp_addlinkedserver actually calls an internal version of sp_addserver called sys.sp_MSaddserver_internal and you will see a new entry in sys.servers after you create a new Linked Server with sys.sp_addlinkedserver.

Is it possible to alter a linked server, i.e. change what it points to, or do you just drop and create again?

I don't see a way to modify where it is pointing, just some of the options.

You can always check for existence before dropping it:

USE [master]
GO

IF EXISTS ( SELECT *
FROM sys.servers
WHERE name = N'Production' )
EXEC dbo.sp_dropserver
@server = N'Production',
@droplogins = 'droplogins';
GO



__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Tobar
Tobar
SSC Veteran
SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)

Group: General Forum Members
Points: 269 Visits: 758
Thanks again.

<><
Livin' down on the cube farm. Left, left, then a right.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search