In this article, I am explaining, How to Linked Server In SQL Server.
There are three way to linked server:-
Using SQL Server Management Studio
To create a linked server to another instance of SQL Server Using SQL Server Management Studio
Ref- https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine?view=sql-server-ver15
There are three way to linked server:-
Using SQL Server Management Studio
To create a linked server to another instance of SQL Server Using SQL Server Management Studio
- In SQL Server Management Studio, open Object Explorer, expand Server Objects, right-click Linked Servers, and then click New Linked Server.
- On the General page, in the Linked server box, type the name of the instance of SQL Server that you are linking to.
To
create a linked server to another instance of SQL Server using
Transact-SQL
In
Query Editor, enter the following Transact-SQL command to link to an
instance of SQL Server named
SRVR002\ACCTG
:
SQLCopy
USE
[master]
GO
EXEC
master.dbo.sp_addlinkedserver
@server
=
N'DOMAIN\SERVER',
--
You need to change Server Name
@srvproduct=N'SQL
Server'
;
GO
Execute
the following code to configure the linked server to use the domain
credentials of the login that is using the linked server.
SQLCopy
EXEC
master
.
dbo
.
sp_addlinkedsrvlogin
@rmtsrvname
=
N'SERVER
NAME',
--
YOU need to change the server name
@locallogin
=
NULL
,
@useself
=
N'True'
;
GO
Ref- https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine?view=sql-server-ver15
No comments:
Post a Comment