sComputer = "SWYNKSRV01" '-- name of the computer where SQL Server is installed sSQLServer = "SWYNKSRV01" '-- name of the SQL server instance containing the database where the target table is located sDb = "Northwind" '-- name of the database containing the target table sTable = "Orders" '-- name of the target table Set oInstance = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _ sComputer & "/root/MicrosoftSQLServer:MSSQL_Table.SQLServerName=" & _ Chr(34) & sSQLServer & Chr(34) & ",DatabaseName=" & Chr(34) & _ sDb & Chr(34) & ",Name=" & Chr(34) & sTable & Chr(34)) Set oOutParam = oInstance.UpdateStatistics() If oOutParam.ReturnValue = 0 Then WScript.Echo "Statistics on indexes of the table " & sTable & " have been updated successfully" Else WScript.Echo "Updating statistics on indexes of the table " & sTable & " failed with the error " & oOutParam.Description End If