How to set up the link:
BEGIN
EXEC sp_addlinkedserver <<remote sql server>>, 'SQL Server';
EXEC sp_addlinkedsrvlogin <<remote sql server>>, FALSE, NULL, '<<sql user on remote server>>', '<<password on remote server>>';
EXEC sp_serveroption '<<remote sql server>>', 'connect timeout', 60;
EXEC sp_testlinkedserver <<remote sql server>>;
END
How to get linked servers:
sp_linkedservers (Transact-SQL) - SQL Server
How to add a linked server:
sp_addlinkedserver (Transact-SQL) - SQL Server
How to add creds to a linked server:
sp_addlinkedsrvlogin (Transact-SQL) - SQL Server
How to test a linked server: