if not exists(select * from sys.servers where name like 'Server1')
begin
exec sp_addlinkedserver 'Server1';
exec sp_addlinkedsrvlogin 'Server1','FALSE',NULL,'userName','Password';
end
First Line is for checking whether the server exists or not, if not making a linked...