I'm trying to switch one of my VBS scripts from using SQLOLEDB to ODBC driver. So long all works like expected - all but one thing:
When fetching SERVERPROPERTY("is_clustered") from an MSSQL instance the resulting value is different using each driver.
Here's the output of an example script (script follows below):
C:\> cscript test.vbs Provider: sqloledb is_clustered (name): is_clustered is_clustered (type): 12 is_clustered (value): 0 Driver: (SQL Server) is_clustered (name): is_clustered is_clustered (type): 204 C:\test.vbs(33, 1) Microsoft VBScript runtime error: Type mismatch
Does anyone know what I'm doing wrong or what I'm missing in my code?
Oh, yes, the code... here's the example script itself:
Option Explicit
Dim RS, CONN1, CONN2
Set RS = CreateObject("ADODB.Recordset")
Set CONN1 = CreateObject("ADODB.Connection")
CONN1.ConnectionTimeout = 2
CONN1.Provider = "sqloledb"
CONN1.Properties("Integrated Security").Value = "SSPI"
CONN1.Properties("Data Source").Value = "HOSTNAME\INST01"
CONN1.Open
WScript.echo "Provider: sqloledb" & vbLf
RS.Open "SELECT SERVERPROPERTY('IsClustered') AS is_clustered", CONN1
WScript.echo "is_clustered (name): " & RS.fields(0).Name
WScript.echo "is_clustered (type): " & RS.fields(0).Type
WScript.echo "is_clustered (value): " & RS("is_clustered") & vbLf
RS.Close
Set CONN2 = CreateObject("ADODB.Connection")
CONN2.ConnectionTimeout = 2
CONN2.ConnectionString = "driver={SQL Server};" & _
"server=HOSTNAME\INST01;" & _
"Trusted_Connection=yes"
CONN2.Open
WScript.echo "Driver: (SQL Server)" & vbLf
RS.Open "SELECT SERVERPROPERTY('IsClustered') AS is_clustered", CONN2
WScript.echo "is_clustered (name): " & RS.fields(0).Name
WScript.echo "is_clustered (type): " & RS.fields(0).Type
WScript.echo "is_clustered (value): " & RS("is_clustered")
RS.Close
Many Thanks in advance!
BR, Marcel