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
 General SQL Server Forums
 New to SQL Server Programming
 Procedural Mombojumbo

Author  Topic 

ConradK
Posting Yak Master

140 Posts

Posted - 2011-01-03 : 10:22:56
So I'm using the sp_addlinkedserver function, and then selecting from that added server, and then dropping that added server.

My code is this:

exec
sp_addlinkedserver 'Diva'
,'ims-server1'
,'SQLNCLI'
,'IMS-SERVER1'


select
*
from
diva.divadb.dbo.items



exec
sp_dropserver @server = 'Diva'

It works if I do each part one at a time, but if I just open and run it, epic fail. Im sure this has to do with procedure, I've tried using ';'s and go and such, but I am fail with them. Can please help?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-01-03 : 10:29:37
How about adding it just once and never dropping it?
Go to Top of Page

SparkByte
Yak Posting Veteran

60 Posts

Posted - 2011-01-03 : 10:53:55
How about

exec
sp_addlinkedserver 'Diva'
,'ims-server1'
,'SQLNCLI'
,'IMS-SERVER1'

GO

select
*
from
diva.divadb.dbo.items

GO

exec
sp_dropserver @server = 'Diva'


UNTESTED (I do not have linked Servers.)



Thank You,

John
Go to Top of Page

ConradK
Posting Yak Master

140 Posts

Posted - 2011-01-03 : 11:06:50
Works, thanks!
Go to Top of Page
   

- Advertisement -