SideBar    Sqlcmd
DOWNLOAD THE CODE:
Download the Code 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.

End of Article

Prev. page     1 2 [3]     next page -->



You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

I can't seem to get this to run. It complains about the MultiServer connection. I followd the article and everything _should_ work, but it isn't. Am I the only one who can't get it to work? I updated the reference to QASRV.DBA_REP to a valid server/db & table on one of my servers. I can populate the ADO recordset successfully, it errors on the ForEach loop...

Error at Populate_DBA_REP [Connection manager "MultiServer"]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.

Also, the ForEach tasks that populate the tables fail validation, I assume because the MultiServer obejct hasn't been populated with a value yet...so it may be acceptable?

Haywood

Article Rating 3 out of 5

Haywood, The connection to QASRV.DBA_REP will be the connection to the repository database itself created from a script provided in the code download. I assume you have created this DBA_Rep database and the QASRV.DBA_REP is pointing to that database. Also, make sure that you can connect to the servers via Management Studio that are in the ADO recordset populated via sqlcmd /Lc in the ServerList_SSIS table. Let me know if I can be of more help getting this working in your environment. (Also, was their a specific SQL error such as "Server does not exist or access denied" message?) Rodney

rlandrum

Article Rating 5 out of 5

*****Note from Author****

Another possible resolution to the issue described in the first reader comment

"Error at Populate_DBA_REP [Connection manager "MultiServer"]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005."

There is a property setting on each of the objects in the package that will delay validation until runtime. I suspect that what is happening is that the package is trying to establish the connection to the MultiServer data source server, which is actually a variable set at runtime. If you set the delay validation object property to TRUE in the object properties (Load Servers Task for example), you should get past the validation issues. Set this property on each object that shows invalid and the package should execute.

rlandrum

Article Rating 5 out of 5

I get the following error on some of my servers, is there a work around for this ? also is there a way to find out which server on the list is generating this error ?

Error 1 Validation error. Load Databases: OLE DB Source [1]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Invalid object name 'tempdb.dbo.HoldforEachDB'.". Populate_DBA_REP.dtsx 0 0

salagheh

Article Rating 4 out of 5

salagheh, Weblisting 3 contains the DDL to create the HoldForEachDB table in TempDB that is required for the validation to complete and for the package to execute locally. Also, after each restart of SQL Server, this table will be deleted because of it's reseidence in TempDB. This only needs to happen on machine where the SSIS package is executing. It will be dynamically created on each target server at runtime. To avoid this, you can also set each objects in the package to delay validation. I have found that this corrects the issue permanently with no need to recreate the HoldForEachDB table. Rodney Landrum (author)

rlandrum

Article Rating 5 out of 5

one issue I see with sqlcmd /Lc is it will only return sql servers listening in its immidiate subnet, which are likely to only be a small subset if all sql servers.

BikeBoy

Article Rating 4 out of 5

I get an error of .....An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x800004005 Description: "Login timeout expired"

sueboo

Article Rating 3 out of 5

I keep getting several errors, seemingly the largest is the problem with the Load Servers task. It always turns red with the OLE DB Source turning red too. I have tried the "delay validation" but it doesn't seem to work. What could be some possible problems and solutions?

sqlmast

Article Rating 3 out of 5

Note from author Make sure that you can connect to each of the server individually via SSMS with the same name as what is in the Serverlist_SSIS table that feeds the variable. Next, make sure you have permissions to access each of the servers in the list. Finally, check the Progress tab for the detailed error and also the Error List and Output windows. Rodney Landrum

rlandrum

Article Rating 5 out of 5

I know that I can connect to each server and I know that I have the rights to the servers. The two top errors that I get are 1) [OLE DB Source [1]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "'SERVERPROPERTY' is not a recognized function name.". 2) [Connection manager "MultiServer"] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E4D Description: "Communication link failure". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E4D Description: "TCP Provider: An existing connection was forcibly closed by the remote host. ". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E4D Description: "Login failed for user '**********\***DBA'.".

-I think that the main problem may be the connection manager in the second part. Maybe the login is wrong. I have a system where I can connect to the servers via windows authentication, but when I remote desktop out to the server, I need to use a special account called ***DBA. I have used '*' to denote company information. Could this be the problem with multiserver? If not I am open to suggestions. Finally, if the author would be interested, I would love to have a discussion, aka learn from the author, about SSIS and the configuration database. I know that it would most likely be a treat for my team to be able to arrange this.

sqlmast

Article Rating 5 out of 5

sqlmast, I would be willing to discuss the article, SSIS, Reporting Services et al with you and your DBA team. My e-mail is posted in the bio if you like to contact me directly. Thank You, Rodney Landrum - author.

rlandrum

Article Rating 5 out of 5

Awesome! Have been wanting something like this for quite awhile since we have been adding SQL instances at an alarming rate. Seemed like such a huge task because I haven't used SSIS much, but your instructions were excellent. Added steps to audit logins, roles and database users. In order to do that I did have to add a default value to the SVR_Conn variable. On to the reports! Thanks again.

abates100

Article Rating 5 out of 5

Great Article...and appreciate the generosity for the code....:)

I did a similar solution and my SSIS package just gets the backup info....But when I connect to SQL2005 servers I get this message...I am executing the SSIS packages from a JOB in SQL2005, the agent account is a domain account and it has access to all servers...I am able to get information for all 2000 servers but 2005 servers have this issue: Any input will be appreciated:

Error: 2007-09-06 02:26:48.54 Code: 0xC0202009 Source: DatabaseBackupsForEachServer Connection manager "Source Conn" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Communication link failure". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Named Pipes Provider: No process is on the other end of the pipe. ". End Error Error: 2007-09-06 02:26:48.55 Code: 0xC020801C Source: Data Flow Task Source [1] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Source Conn" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error

rsqlmag

Article Rating 5 out of 5

Great article, this is going to be immensly useful! One bit of info, not explicitly stated, that I was having trouble finding, is how the connection is dynamically set. You have the variable set, but never mention that. For those who might be having the same problem finding this vital bit of info(ssis beginners unite!), it is set in the connection manager as an expression: @[User::SRV_Conn].

sgreene

Article Rating 5 out of 5

rsqlmag, This could be caused by a number of things. Here are a couple to check out. Named Pipes is not enabled by default. If for whatever reason a Named Pipe connection is being tried for the 2005 servers you can enable it via the SQL Server Configuration Manager under SQL Server 2005 Network Configuration. Also, make sure that remote connections are allowed. This can be enabled with the Surface Area Configuration for Services and Connections. Set Remote Connections to use both, or if local connections only is checked select, allow local and remote connections. On SQL Server Express, Local connections only is the default if I am not mistaken. Hope this helps. Rodney Landrum - author.

rlandrum

Article Rating 5 out of 5

See More Comments  1   2