Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Server Job -- What Server am I on?

Status
Not open for further replies.

DBAchick

Programmer
Apr 27, 2000
61
I have created a job that will be executed as a Multi-Server job. The first step is an ActiveX Script in which I need to query the sysdatabases table in order to get a recordset of the databases on that server.

In order to run the Select statement, I am creating a connection string that includes the server I am current running against. How do I 'code' for the variable servername?

I have tried:

sServerName = [SRVR] (no good, cannot set a variable = [SRVR] in Active X)

Running a step before this one using @@SERVERNAME assigned to a global variable (sServerName).

Here is my code: (sServerName is the variable I need set with the current server)

sSelectDbName="SELECT name as DbName FROM sysdatabases WHERE name not in ('master','model','tempdb','msdb') and len(name) = 7"
Set cn = CreateObject("ADODB.Connection")
Set rsDbName = CreateObject("ADODB.Recordset")
cn.Provider = "sqloledb.1"
cn.Properties("Initial Catalog").Value="Master"
cn.Properties("Data Source").Value=sServerName
cn.Properties("Application Name").Value = "Populate SQL Users"
cn.Properties("Integrated Security").Value = "SSPI"
cn.Open

Any ideas for me??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top