DATABASE

SQL Server 2008 : Working with Multiple-Source Queries - Using Four-Part Database Names & The DTC Explained

1/20/2011 3:57:59 PM

Using Four-Part Database Names

If the data is in another SQL server, complete the four-part name that is required to access data from the remote SQL server. Server.Database.Schema.ObjectNameSELECT or DML query. For SELECT, here is the query. is the four-part name. The four-part name may be used in the

SELECT * FROM [<server_name,sysname,(local)><instance_name,sysname,\
SQLEXPRESS>].<database_name,sysname,pubs>.<schema_name,sysname,dbo>.
<table_name,sysname,authors>
GO
Example: SELECT Name, Address FROM RMTSERVER.AdventureWorks.Person.Address

In case of other database types, often you won’t find the schema name. For example, in the MS Access example, you won’t see a database and schema with a match to the SQL server. In those cases you can avoid them by notation as given in the following example.

SELECT * FROM CUSTOMERACCESS...Customer

The DTC Explained

SQL Server uses the Distributed Transaction Coordinator (DTC) to handle multiple-server transactions, commits, and rollbacks. The DTC server uses a two-phase commit schema for multiple-server transactions. Here are the steps.

  1. Server is sent a prepare to commit message.

  2. Server performs the first phase of the commit, verifying that it is capable of committing the transaction.

  3. Server replies when it has finished preparing for the commit.

  4. After server has responded positively to the prepare to commit message, the actual commit message is sent to each server.

  5. DTC is required only when remote updates are occurring in the remote server.

Tip

There are three catalog views related to Linked Servers: sys.linked_logins, sys.servers, and sys.remote_logins. The most frequently used catalog view is sys.servers.

  SELECT * from sys.servers
WHERE is_linked = 1

The preceding query will return the list of linked servers attached to a SQL server.

Other  
  •  SQL Server 2008 : Working with Multiple-Source Queries - Using Linked Servers
  •  OData with SQL Azure - Enabling OData on an Azure Database
  •  OData with SQL Azure - OData Overview
  •  SQL Server 2008 : Performing Nonlogged DML Operations
  •  SQL Server 2008 : Using the OUTPUT Clause with the MERGE Statement
  •  SQL Server 2008 : Returning Data from DML Operations Using the OUTPUT Clause
  •  SQL Server 2008: Working with System Databases
  •  SQL Server 2008 : Using @@IDENTITY and NEWID Functions in DML Statements
  •  SQL Server 2008 : Using Advanced Functionality with DML - Introduction
  •  Defensive Database Programming with SQL Server: The Ticket-Tracking System (part 2) - Removing the performance hit of ON UPDATE CASCADE
  •  Defensive Database Programming with SQL Server: The Ticket-Tracking System (part 1) - Enforcing business rules using constraints only
  •  SQL Server 2008 : Working with DML Queries - Using the MERGE Statement
  •  Defensive Database Programming with SQL Server : Client-side Error Handling
  •  SQL Server 2008 : Working with DML Queries - Using the DELETE Statement
  •  Programming Microsoft SQL Server 2005: Using Data Mining Extensions (part 2) - Data Mining Predictions Using DMX
  •  Programming Microsoft SQL Server 2005: Using Data Mining Extensions (part 1) - Data Mining Modeling Using DMX
  •  SQL Server 2008 : Working with DML Queries - Using the UPDATE Statement (part 2)
  •  SQL Server 2008 : Working with DML Queries - Using the UPDATE Statement (part 1)
  •  Azure Programming Considerations
  •  Programming with SQL Azure : Record Navigation in WCF Data Services
  •  
    Most View
    Installing Exchange Server 2010 : Installing dedicated server roles
    iPad Therapy (Part 2) - There’s an app for that
    Best Photo Printers Revealed – Jan 2013 (Part 2) : Canon PIXMA MG6250
    XNA Game Studio 4.0 : Windows Phone Sensors and Feedback (part 2) - Locating a Windows Phone with the Location Service
    Buying Guide: High-end CPUs (Part 3) - Intel Core I7-3770K, Intel Core i7-3930K, Intel Core i7-3970X
    Introducing IIS 7
    Dell Inspiron One 23 - An Adequate All-In-One Desktop PC
    Cisco Linksys X3000 - The Link to Connectivity
    What To Look For When Buying A New Phone Or Tablet (Part 10)
    Philips 7000 Series 46PFL7007 Smart LED 3D TV
    Top 10
    ADO.NET Programming : Microsoft SQL Server (part 4) - Working with Typed Data Sets
    ADO.NET Programming : Microsoft SQL Server (part 3) - Using Stored Procedures with DataSet Objects
    ADO.NET Programming : Microsoft SQL Server (part 2) - Using SQL Server Stored Procedures
    ADO.NET Programming : Microsoft SQL Server (part 1) - Connecting to SQL Server, Creating Command Objects
    Windows Phone 8 In-Depth Review (Part 6)
    Windows Phone 8 In-Depth Review (Part 5)
    Windows Phone 8 In-Depth Review (Part 4)
    Windows Phone 8 In-Depth Review (Part 3)
    Windows Phone 8 In-Depth Review (Part 2)
    Windows Phone 8 In-Depth Review (Part 1)