SQL server, linked server error with open query -


i can't figure out why getting error on open query line:

"could not find server 'server_name' in sys.servers. verify correct server name specified. if necessary, execute stored procedure sp_addlinkedserver add server sys.servers."

when run code in parts works...

if not exists(select * sys.servers name = server_name)  begin          exec sys.sp_addlinkedserver                 @server = server_name, @srvproduct = 'sql server'         exec sys.sp_addlinkedsrvlogin                 server_name, 'false', null, 'username', 'password' end  select * openquery(server_name, 'select * table')   if exists(select * sys.servers name = server_name)          exec sys.sp_dropserver @server = server_name, @droplogins = 'droplogins' 


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -