• subscribe
April 19, 2007 12:00 AM

SQL Server Integration Services

Gather information automatically
SQL Server Pro
InstantDoc ID #95385
Downloads
95385.zip

My solution was to query each database to return database-specific information in a table that I created in the TempDB database. The table I created wasn't a true temporary table with a # or ## prefix. Although the table resides in the TempDB database, its size and location have minimal effect on the source server. Web Listing 3 contains the code to create and populate this table, called HoldForEachDB. Notice the syntax of the sp_MSForEachDB stored procedure, which substitutes a question mark for the database name. This command is fairly useful, without requiring you to wrap logic into cursors to provide similar functionality. (Note: When you save the task, you might receive a message such as "The DROP table construct statement is not supported." However, the query will still delete the table and repopulate it with crucial database information such as status, recovery model, size, and updateability.)

Troubleshooting
The package runs on both SQL Server 2005 and 2000 servers. If no errors generate, the package will run in less than 2 seconds for 2 servers and in less than 2 minutes for 30 servers with varying amounts of data. If the package runs successfully and each package object turns green, you're ready to query the repository with custom queries and reports. Even if the package objects don't all turn green, don't worry—each task has a maximum error value that you can set to let the package continue running even if it can't connect to an individual server, for example.

Servers fail to connect for various reasons—for example, they might not be online, or the user running the package doesn't have access. You can use event handling to send an email message or write to a log to report server failures. Event handling, logging, and scheduling the SSIS package for automatic runs are beyond the scope of this article. For more information about these tasks, see SQL Server Books Online (BOL).

After you load the database, you can run a simple query such as the following:

SELECT [Server]
,\[ProductVersion]
,\[ProductLevel]
,\[IsIntegratedSecurityOnly]
,\[EngineEdition]
,\[Collation]
,\[IsClustered]
,\[IsFullTextInstalled]
,\[SqlCharSet]
FROM [DBA_Rep].[dbo].[SQL_ 
Servers] 

This query provides the data that Table 1 shows, which includes useful information about the two servers I used to test the package.

You've got the Power
The package I created is just one example of what you can do with SSIS. Combining the variable and expression values gives you unprecedented control and efficiency in designing packages. For my package, I used variables and expressions to programmatically control a connection string to query multiple servers without needing to manually define each connection.



ARTICLE TOOLS

Comments
  • David
    3 years ago
    Jan 06, 2009

    Great article, thank you for sharing the code

  • Ludwig
    4 years ago
    Feb 12, 2008

    I was that DBA... ;)

    For me was better to get the list of the Available Sql Servers using (c#), to avoid use link servers or MultiServer connection to get the information:

    using Microsoft.SqlServer.Management.Smo.RegisteredServers;
    SmoApplication.EnumAvailableSqlServers(false)
    returns a DataSet

    Now I want to improve my project.

    References:
    http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.smoapplication.enumavailablesqlser
    vers.aspx

    Thanks.

  • Anne
    4 years ago
    Jan 29, 2008

    dmbranscome, I'm glad you find the article valuable. Check out Rodney's follow-up article on his SSIS/SSRS solution in the Feb. issue of SQL Server Magazine, online at http://www.sqlmag.com/Article/ArticleID/97840/sql_server_97840.html.

  • David
    4 years ago
    Jan 15, 2008

    at a minimum the article provides further examples of SSIS implementations.
    This should be good. Thanks dmb

  • Rick
    5 years ago
    Nov 21, 2007

    Don't know if anyone has pointed this out, but we seemed to have trouble with named instances on servers with more than the default. Discovered that we had to use Servername and port instead of Servername\\Instance. That seems to work.

You must log on before posting a comment.

Are you a new visitor? Register Here