Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (31 sloc)
778 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Procedure to make create of SQL Server Linked server easier | |
Alexis Comte | |
alexis.comte@capit.net | |
*/ | |
CREATE PROCEDURE [dbo].[AddLinkedServer] | |
@srvname SYSNAME | |
, @srvlogin SYSNAME | |
, @srvPassword SYSNAME | |
AS | |
BEGIN | |
IF NOT EXISTS | |
( | |
SELECT 1 | |
FROM sys.servers | |
WHERE name = @srvname | |
) | |
AND @srvlogin IS NOT NULL | |
AND @srvPassword IS NOT NULL | |
BEGIN | |
EXEC sp_addlinkedserver @server = @srvname; | |
EXEC sp_addlinkedsrvlogin @rmtsrvname = @srvname | |
, @useself = 'false' | |
, @rmtuser = @srvlogin | |
, @rmtpassword = @srvpassword; | |
END; | |
EXEC sp_serveroption @server = @srvname | |
, @optname = 'collation compatible' | |
, @optvalue = 'true'; | |
END; | |
GO | |