Querying Multiple Servers in SQL Server 2008

SQL Server 2008 provides the functionality of querying multiple Servers from a single query window. This is helpful for tasks like retrieving server information such as Version, Edition, Instance Name, logins available across each instance, databases on the servers etc.

In order to query multiple servers the only prerequisite is that the servers need to be registered prior to run the query and of course, there should be a valid login to connect to those Server. The SQL Servers can be of other version such as SQL 2000 or 2005. In this example I have two SQL Server 2005 instances and one SQL Server 2008 instance all of them are installed on a single Machine.

For the purpose of this article, I assume you know how to register a SQL Server in the Local Server Groups. Open registered servers from View menu or using keyboard short-cut Ctrl + Alt+ G (picture below).

 

Right click on the server group, from the pop up menu choose New Query as shown in the picture below.

 A new query editor is opened which has is similar to a normal new query editor. The only difference you find is the status bar down at the the bottom of the query editor. The picture below displays the status bar and we see the difference with a usual query editor status bar. This status bar does not a single instance name rather, displays the Server Group Name, also SPID information is not displayed.

I am running a simple query to retrieve the list of the user Databases on all the instances in the server group. The query results is displayed along with the query. The Database names are displayed along with SQL Instance name.

Those of us who would like to find the backup information of the critical databases or to find the SQL Agent Jobs that failed across several instance, that can all be done from a single query in SQL Server 2008.

Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru that let’s you know when there is a new blog post.

–Bru Medishetty

Installing .NET 3.5 Framework in Windows Server 2008 R2

This article will guide through the steps to install .NET Framework 3.5 on a Windows Server 2008 R2.

I recently installed and started working on a Windows Server 2008 R2 Enterprise. I started installing SQL Server and I knew SQL Server 2008 requires the Microsoft .NET Framework 3.5 to be installed on the machine. The installation wizard displayed the following message box (picture below), which is common. (as I had previously installed SQL Server 2008).

I clicked OK button and the setup started loading the required components and immediately displayed the error message (picture below), asking to install .NET Framework from Role Management Tool.

To install roles on a Windows Server the roles have to be added in the Server Manager. So I opened the Roles node from the tree structure in the Server Manager and what you see below is what it looks like (only required portion of the screen is shown to make the images smaller and tidy). On the right side, Add Roles is available and we need to select / click that.

Upon selecting Add Roles, the Add Roles Wizard is displayed as shown below. I selected Application Server and on selecting it, there is a description available on the right side, what that role is going to provide or include.

The following information message box is displayed informing that to install an Application Server, there are certain other required features we need to include. All we need to do is to click the Add required features button in the message box.

It would then display the dialog box giving a short information of what an Application Server does. Click Next to continue.

I choose some additional roles apart from Application Server role, and the dialog box below is a confirmation of all the selections, click install to start the installation process.

The Installation begins. (Picture Below)

The installation is successful and the picture below is the dialog box confirming the success of the installation of the roles that we have chosen.

With that, the prerequisite for installing a SQL Server 2008 Instance is met, and we can continue installing SQL Server 2008.

Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru that let’s you know when there is a new blog post.

–Bru Medishetty

Linked Server with Access 2007 Database

This article will explain the steps to create and using a Linked Server on an Access 2007 Database. The steps include creating a Linked Server using GUI and through T-SQL script.

The picture below displays location of the 2 Access Databases (My Documents directory) used in this exercise.

To create a Linked Server using the New Linked Server dialogs, start at the Server Objects in the Object Explorer in SSMS. Expand Server objects and on the Linked Servers, right click and select New Linked Server. (Picture below)

In the New Linked Server dialog box, type the linked server name that you would like to create and use (It is
not a must to have the actual name of the Access database, in the example we are naming
LINKEDSERVER_ACCESS
. For Server type, choose Other data source, and for Provider from the drop down
list, choose Microsoft Office 12.0 Access Database Engine OLE DB Provider.

For the Product Name, type ACCESS and for the data source give the location where the access database is located. (Picture below)

After entering above mentioned details, select the Security Page in the left hand pane of the dialog box. In the security settings choose the option Be made using the login’s current security context. Click Ok and the Linked Server is created.

The picture below displays the query to update a table and select statement to retrieve the table data.

Alternately you can add a linked server using the system stored procedure sp_addlinkedserver in the Master DB. The picture below shows the parameters for the stored procedure such as servername, srvproduct, provider and the datasource. After adding the Linked Server, the next query is a select statement to select few records from the newly created Linked Server.

 Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru that let’s you know when there is a new blog post.

–Bru Medishetty