Your SlideShare is downloading. ×
How to Configure, Manage, Use, and Troubleshoot Linked ...
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

How to Configure, Manage, Use, and Troubleshoot Linked ...

731
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
731
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. How to Configure, Manage, Use, and Troubleshoot Linked Servers With Microsoft SQL Server William P. Carroll SQL Server Support Engineer Microsoft Corporation
  • 2. Objectives and Agenda
    • Understand how Microsoft® SQL Server™ implements linked servers
    • How to set up and configure linked servers
    • Different techniques for writing linked server queries
    • How to troubleshoot common linked server issues
    • Questions and answers
  • 3. Introduction and Architecture (2)
    • What are linked servers?
      • Link to a remote data source
      • The link uses an OLE DB provider
      • SQL Server will use the link to run commands against the OLE DB provider for the remote data source
    • The functionality of the OLE DB provider will determine what commands and functions the linked server can accomplish
  • 4. Introduction and Architecture (3)
    • What are OLE DB providers?
      • Microsoft created OLE DB
      • OLE DB is an open set of component object model (COM) interfaces that provide applications with consistent access to data stored in diverse sources
    • All linked servers use OLE DB
    • OLE DB providers are installed with MDAC or third-party installation packages
  • 5. Introduction and Architecture (4)
    • ODBC versus OLE DB
    • ODBC
      • Established standard for accessing relational database systems
    • OLE DB
      • Can access relational database systems and non-relational database systems
    • MSDASQL
  • 6. Introduction and Architecture (5)
    • Linked servers versus remote servers
      • Remote servers permit a client to connect to one instance of SQL Server and run a stored procedure on another instance of SQL Server without the client establishing another connection
      • Remote servers remain only for backward compatibility
      • Remote servers do not use OLE DB providers
      • Try to convert remote servers to linked servers
  • 7. Introduction and Architecture (6)
    • SQL Server address space
  • 8. Introduction and Architecture (7)
    • Linked server architecture
  • 9. Introduction and Architecture (8)
    • OLE DB providers tested with SQL Server 2000
      • Microsoft OLE DB provider for SQL Server
      • Microsoft OLE DB provider for ODBC
      • Microsoft OLE DB provider for jet version 4.00
      • Microsoft OLE DB provider for DTS packages
      • Microsoft OLE DB provider for Oracle version 2.6
      • Microsoft OLE DB provider for Microsoft directory services
      • Microsoft OLE DB provider for Microsoft indexing services
      • Microsoft OLE DB provider for DB2
  • 10. Setup and Configuration
  • 11. Setup and Configuration (2)
  • 12. Setup and Configuration (3)
  • 13. Setup and Configuration (4)
  • 14. Setup and Configuration (5)
  • 15. Setup and Configuration (6)
    • Sp_addlinkedserver
    • Sp_addlinkedsvrlogin
    • Sp_serveroption
    • Sp_dropserver
    • Sp_droplinkedsvrlogin
    • Sp_linkedservers
    • Sp_helpserver
    • xp_enum_oledb_providers
    • Select * from master..sysservers
    • HKEY_LOCAL_MACHINESoftware MicrosoftMicrosoft SQLServerProviders
  • 16. Setup and Configuration (7)
    • Security account delegation
    • All servers must be running Windows 2000 with Kerberos support enabled, and must be using Microsoft Active Directory®
    • Active Directory must be configured
    • Must use TCP/IP
    • The service principal name (SPN) must be assigned to the service account of the SQL Server service on that specific computer (setspn.exe)
  • 17. Using Linked Servers
    • Linked_server_name.Catalog.Schema.Object_name
    • Sp_tables_ex, sp_columns_ex
    • Select * from sql2.pubs.dbo.authors
    • Select * from ora2..SCOTT.DEPT
    • Select * from mdb2…customer
    • Join multiple tables, join local and remote tables
  • 18. Using Linked Servers (2)
    • OPENQUERY ( linked_server , ' query ' ).
    • Select * from openquery (server2, ‘select * from authors’)
    • For parameters, build openquery dynamic string, then run the string
    • If performance becomes an issue with four part name syntax, test with openquery syntax
  • 19. Using Linked Servers (3)
    • Insert openquery (server2, ‘select * from northwind.dbo.products’) values (78, ‘TestName’, 1, 1, ‘10 boxes’,18.000, 20, 0, 10, 0)
    • Update openquery (server2, ‘select * from northwind.dbo.products where productid = 2’) set ProductName= ‘Smith’
    • Delete from openquery (server2, ‘select * from northwind.dbo.products where productid = 78’)
  • 20. Using Linked Servers (4)
    • OPENROWSET ( ' provider_name '     , { ' datasource ' ; ' user_id ' ; ' password '         | ' provider_string ' }     , { [ catalog . ] [ schema . ] object         | ' query ' }     )
    • No linked server has to be defined
  • 21. Using Linked Servers (5)
    • Can run remote stored procedures for SQL Server
    • Exec server2.Master..Sp_who
    • Cannot run remote stored procedures for Oracle
  • 22. Using Linked Servers (6)
    • Set xact_abort on
    • Most OLE DB providers require xact_abort to be set to on for data modification statements in an implicit or explicit transaction
    • Set xact_abort on
    • begin distributed tran
    • --distributed query 1
    • --distributed query 2
    • commit tran
  • 23. Troubleshooting
    • 7399 error is a generic multipurpose error from SQL Server
    • Dbcc traceon(7300, 3604)
    • Trace flag 7300 receives error information from the OLE DB provider and 3604 shows it to the client
    • Capture “OLE DB Errors” event in “Errors and Warnings” event category in SQL Profiler
  • 24. Troubleshooting (2)
    • Determine if the problem is with SQL Server (linked server configuration or query plan) or the OLE DB provider
    • RowsetViewer.exe
  • 25. Troubleshooting (3)
    • 17803 Insufficient memory available
    • Run Instcat.sql on SQL Server 6.5
    • Set Statistics profile on
    • Oracle: Q280106, Q244661
    • DB2: Q222937, Q218590, Q287093
  • 26. Additional Resources
    • Q203638, “HOWTO: Return Information About SQL Server Linked Servers”
    • Q280106, “HOWTO: Set Up and Troubleshoot a Linked Server to Oracle in SQL Server”
    • Q207595, “HOWTO: SQL Server 7.0 Distributed Query With FoxPro .dbf Files”
    • Q246255, “HOWTO: Use a SQL Server 7.0 Distributed Query w/ Linked Server”
    • Q314520, “HOW TO: Pass a Variable to a Linked Server Query”
    • Q244661, “INF: Limitations of Microsoft Oracle ODBC Driver and OLEDB Provider”
    • Q197456, “INF: Optimizing Distributed Query with Numeric Predicates”
    • Q274348, “INF: Distributed Queries Executed Within a Trigger Enlist MSDTC”
  • 27. Additional Resources (2)
    • Q222937, “INF: Creating a Linked Server to DB2 w/ OLE DB Provider for DB2”
    • Q218590, “INF: Configuring Data Sources for the Microsoft OLE DB Provider for DB2”
    • Q242025, “INF: How to Set Up Security for Linked Server to OLAP Services”
    • Q271669, “INF: Distributed Queries are not Run as Parallel Query Steps”
    • Q277002, “PRB: Distributed Query Against Oracle 8.x Fails”
    • Q278984, “PRB: Error 7321 Occurs When You Run a Query That Uses Four-Part Names Against DB2 on an AS/400 Computer”
    • Q270119, “PRB: 7357/7320 Error While Performing UPDATE, INSERT, or DELETE on Remote Table Using OpenQuery Via Linked Server”
  • 28. Additional Resources (3)
    • Q220915, “PRB: SQL Distributed Query with Oracle Needs Oracle Client and Networking Components”
    • Q286464, “PRB: Error 7008 Occurs When Using DB2OLEDB Provider with DB2/400”
    • Q200797, “PRB: OPTIMIZER LOCK HINTS Error with Open Query”
    • Q200794, “PRB: Sp_addlinkedserver Does Not Validate the OLE DB Provider”
    • Q240340, “PRB: SQL Distributed Query w/ Oracle "Could not open table" Error”
    • Q306649, “PRB: Error When You Implement Nested Transaction with OLE DB Provider for SQL Provider”
    • Q238477, “PRB: Message 18456 from a Distributed Query”
    • Q230576, “PRB: Dist. Query Involving External Provider Not Supported When Using Windows NT Authentication”
  • 29. Additional Resources (4)
    • Q221552, “PRB: SQL Distributed Query with Oracle NUMERIC Column Gives Error”
    • Q296685, “FIX: Cannot Execute SELECT COUNT(*) Against DB2 on Mainframe Using Four-Part Name”
    • Q281185, “FIX: Linked Index Server Query Through OLE DB Provider with OR Clause Reports Error 7349”
    • Q293758, “FIX: Nullability Changes Not Handled by SQL Server with Linked Server Queries to DB2”
    • Q306401, “FIX: Error Message 7355 "..Inconsistent metadata for a column" Occurs When You Use a Linked Server”
    • Q265865, “FIX: Float Data Inaccurately Converted When Sent to Linked Server”
  • 30. Questions and Answers
  • 31.
    • Thank you for joining today’s Microsoft Support
    • WebCast.
    • For information about all upcoming Support WebCasts,
    • and access to the archived content (streaming media
    • files, PowerPoint ® slides, and transcripts), visit:
    • http:// support.microsoft.com/webcasts /
    • Your feedback is sincerely appreciated. Please send any
    • comments or suggestions about the Support
    • WebCasts to [email_address] .

×