Tweet
SIGN UP
MEMBER LOGIN:
TECHNOLOGIES
.NET 4.5
.NET Remoting in C#
Active Directory C#
ADO.NET in C#
AJAX in C#
Algorithms in C#
Android Programming
Articles C#
ASP, JavaScript, CSS
ASP.NET Controls in C#
ASP.NET MVC with C#
ASP.NET Programming
BizTalk Server
C# Assemblies
C# Language
C# Tutorials
C, C++, MFC
Career Advice
Chapters
Cloud Computing
COBOL.NET
Coding Best Practices
COM Interop
Compact Framework
Cryptography C#
Crystal Reports C#
Current Affairs
Custom Controls C#
Databases & DBA
Deployment
Design & Architecture
DirectX C#
Enterprise Development
Error Zone
Exception Handling C#
Expression Studio
F#
Files, Directories in C#
Financial Applications
Games Programming C#
GDI+ & Graphics
Hardware
How do I
HTML 5
Internet & Web
iPhone/iPad
Java
Java and .NET
JQuery
JSP
Leadership
Learn .NET
LINQ with C#
Metro Style Apps in C#
Mobile & Embedded
MonoDevelop
MSMQ in C#
Multithreading in C#
Networking
Office Development
OOP/OOD
Operating Systems
PHP
Printing in C#
Products
Project Management
Reports using C#
Robotics & Hardware
Security in .NET
SharePoint
Silverlight with C#
Smart Devices
Speech in C#
SQL
SQL Server 2012
String in C#
Team Foundation & VSS
Testing
Visual Basic .NET
Visual C#
Visual Studio .NET
Visual Studio 11
Visual Studio 2010
VS LightSwitch 2011
WCF with C#
Web Forms C#
Web Services in C#
WebForms Controls
Windows 8 in C#
Windows Controls C#
Windows Forms C#
Windows Phone in C#
Windows PowerShell
Windows Services in C#
Workflow Foundation in C#
WPF with C#
XAML with C#
XML in C#
XNA with C#
FORUMS
BLOGS
VIDEOS
INTERVIEWS
CERTIFICATIONS
DOWNLOADS
BOOKS
LINKS
NEWS
Learn .NET in 60 days – Part 1 (13 Labs)
Learn MVC (Model view controller) Step by Step ...
Learn C# Corner - Home
Using Border Radius and Gradients in CSS3: Part I
Learn C# Corner - Footer
Learn .NET and C# in 60 Days Lab13(Day 5): - C ...
iPhone 5 First Look
Samsung Galaxy Note Review
WCF - Authentication and Authorization in Ente ...
How to write a good article on C# Corner
Blog
Add Linked Server
Posted by
Gaurang Upadhyay
in
Blogs
|
SQL
on
Feb 09, 2012
Creates a linked server, which allows access to distributed, heterogeneous queries against OLE DB data sources
Tweet
435
0
0
Purpose of Linked Server :
The system stored procedure SP_AddLinkedServer is used in order to link a server from the server in which you are executing the command. In order to connect to a remote SQL Server.
For example :
Suppuse you have Sql server Name With : Node15 Database Name : Users
Now you have other Sql server Name : Node17 Database Name : Employee
Now you want to show some reocrd of employee in your Application which is attached with Node15. So at that time Linked server is Useful.
Here the step to execute and you will get the records from Other database server.
Step 1 :
EXEC
sp_addlinkedserver
@server = 'YourSqlServerName'
Here @ServerName : Give Sql Server Name in which you want to connect
Step 2 :
EXEC sp_
addlinkedsrvlogin
@rmtsrvname='YourSqlServerName', @Useself='False',@locallogin=NULL,
@rmtuser='UserName', @rmtpassword='Password'
@rmtuser : Give User name of the database which you want to connect
@rmtpassword : Give Password of the database which you want to connect
Step 3 :
Select * from [YourDatabaseName].[DatabaseName].dbo.TableName
Now By this query you can fetch the record.
Step 4 :
To remove the link with server which you connected.
EXEC
Sp_DropServer
@Server= 'YourSqlServerName',@droplogins='droplogins'
Notice : If you want to Insert ,Update Or delete on the same way you can do with linked server.
---------------------
Thanks & Regards
Gaurang Upadhyay
Sr. Developer
share this blog :
Leap Year Logics In SQL Server
Join Fundamentals in SQL
Related Blogs
Use of Linked Server IN Sql Server
ALTER TABLE ALL Foreign Keys to add ON DELETE CASCADE
SQL Server Compact 4.0 Installation and Visual Studio 2010 Integration
Data types in SQL Server 2000
Cursors use in SQL Server
Get current date In sql server ,oracle and MYSQL
post comment
Sponsored by
Become a Sponsor
More Blogs from this Blogger
Add Linked Server
NullIf function in Sql server
SQL COALESCE Function
Operation is not valid due to the current state of the object.
View All
Latest Blogs
Free Ride is Over for Desktop Developers in Visual Studio 11
DotNet developers most used application/tools launching through 'Run'
80-inch Windows 8 Tablet
Data encapsulation
Option to access the Column Names in Data table
Open multiple windows in browser startup. (Multiple homepages option)
I'm Sorry
const and readonly
Address, Binding and Contract in WCF
JQuery Maxchars Plugin
View All
Sponsored by
Become a Sponsor