DECLARE @var_server NVARCHAR(MAX) = 'jqadbtest.qa.j.intershop.de', @var_locallogin NVARCHAR(MAX) = 'intershop', @var_currentlogin NVARCHAR(MAX) = 'INTERSHOPNET\MSeidel', @var_rmtuser NVARCHAR(MAX) = 'mseideledit', @var_rmtpassword NVARCHAR(MAX) = 'mseideledit'; -- If the server do exists: -- EXEC sp_dropserver @var_server, 'droplogins' EXEC sp_addlinkedserver @server = @var_server, @srvproduct=N'SQL Server' EXEC sp_addlinkedsrvlogin @rmtsrvname=@var_server,@useself=N'False',@locallogin=@var_locallogin,@rmtuser=@var_rmtuser,@rmtpassword=@var_rmtpassword EXEC sp_addlinkedsrvlogin @rmtsrvname=@var_server,@useself=N'False',@locallogin=@var_currentlogin,@rmtuser=@var_rmtuser,@rmtpassword=@var_rmtpassword EXEC sp_serveroption @server=@var_server, @optname=N'collation compatible', @optvalue=N'false' EXEC sp_serveroption @server=@var_server, @optname=N'data access', @optvalue=N'true' EXEC sp_serveroption @server=@var_server, @optname=N'dist', @optvalue=N'false' EXEC sp_serveroption @server=@var_server, @optname=N'pub', @optvalue=N'false' EXEC sp_serveroption @server=@var_server, @optname=N'rpc', @optvalue=N'false' EXEC sp_serveroption @server=@var_server, @optname=N'rpc out', @optvalue=N'false' EXEC sp_serveroption @server=@var_server, @optname=N'sub', @optvalue=N'false' EXEC sp_serveroption @server=@var_server, @optname=N'connect timeout', @optvalue=N'0' EXEC sp_serveroption @server=@var_server, @optname=N'collation name', @optvalue=null EXEC sp_serveroption @server=@var_server, @optname=N'lazy schema validation', @optvalue=N'false' EXEC sp_serveroption @server=@var_server, @optname=N'query timeout', @optvalue=N'0' EXEC sp_serveroption @server=@var_server, @optname=N'use remote collation', @optvalue=N'true' EXEC sp_serveroption @server=@var_server, @optname=N'remote proc transaction promotion', @optvalue=N'true' GO