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??
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"
cn.Properties("Data Source"
cn.Properties("Application Name"
cn.Properties("Integrated Security"
cn.Open
Any ideas for me??