I have a programm that create linked server on start of application and delete it on finish.
I need to check if linked server already exist on my server.
How can i do it?system catalog: SYSSERVERS|||The easy way would be to check the return code from sp_addlinkedserver (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_adda_8gqa.asp).
-PatP|||Hi gorodd,
Assuming you have a server called "goroddServer"
if exists (select srvname from master.dbo.sysservers where srvname = goroddServer)
begin
print 'goroddServer already exists and is dropped'
exec sp_dropserver goroddServer
end
You may not want the print statement but I have it in for debugging purposes
Hope this helps
Richard
No comments:
Post a Comment