C++/VB - SQL Version (Build) with WMI
Asked By Mick
05-Feb-10 05:01 AM
Hello ng
How can I get the SQL-Server Version and Edition with WMI or registrykey?
This server is patched with SP3 and CU5. The BuildNumber is 10.0.2746.0 now.
This RegistryKey give only the basic insallation version, not with updates.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\BIDS\Setup]
With this SELECT I can list what I want, but I search a WMI querie.
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('edition')
10.0.2746.0
Enterprise Edition (64-bit)
thanks for your help
Mick
ADODB.Connection
(1)
SQL Server
(1)
ADODB.Recordset
(1)
ADODB
(1)
AdoRecordset.MoveNext
(1)
VBScript
(1)
AdoRecordset.Source
(1)
AdoRecordset.Fields
(1)
Richard Mueller [MVP] replied to Mick

I would use the T-SQL @@VERSION function in a query to get the SQL Version.
I use ADO in a VBScript program to run SQL statements, but you can also use
query analyzer or isql or a similar utility. The T-SQL statement is:
SELECT @@VERSION AS Version
A VBScript solution could be:
=============
' SQLVersion.vbs
' VBScript program to query SQL Server version.
Option Explicit
Dim strConnect, adoConnection, adoRecordset, strVersion
strConnect = "DRIVER={SQL Server};" _
& "Trusted_Connection=Yes;" _
& "DATABASE=MyDatabase;" _
& "SERVER=MyServer\MyInstance"
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.ConnectionString = strConnect
adoConnection.Open
Set adoRecordset = CreateObject("ADODB.Recordset")
Set adoRecordset.ActiveConnection = adoConnection
adoRecordset.Source = "SELECT @@VERSION AS Version"
adoRecordset.Open
Do Until adoRecordset.EOF
strVersion = adoRecordset.Fields("Version").Value
Wscript.Echo strVersion
adoRecordset.MoveNext
Loop
' Clean up.
adoRecordset.Close
adoConnection.Close
========
My connection string assumes a named instance and Windows Integrated
Authentication.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Mick replied to Richard Mueller [MVP]
Newsbeitrag
Hello Richard
Exactly I looked for that!
Thanks a lot.
Greets from Switzerland.
Mick
Connection to SQL Server on Vista C++ / VB I have VB6 application which connects to SQL Server 2000 (installed on the developer machine) database. I use this code to connect: strConnectionString = "DRIVER = SQL Server;SERVER = (local);UID = ;DATABASE = Coordinator;Trusted_Connection = Yes" objConn.Properties("Extended Properties") = strConnectionString objConn.Open Everything works I see it's OS. Any suggestion please Thank you vovan VB DataBase ADO Discussions ADODB.Connection (1) SQL Server 2000 (1) SQL Server (1) Windows XP (1) Visual Studio (1
passwords for SA C++ / VB I need to develop a script to connect to each SQL Server server, each instance and each database, to verify if the SA and its password is matching have more than one instance. Each instance has more than one database. I have the server and their respective password for the SA. I just need to confirm if their passwords are matching. Does anybody know the best way to do that? Thanks, Felipe VBScript Discussions ADODB.Connection (1) SQL Server (1) ADODB (1) Database (1) Fonseca (1) França (1) Heres (1) Sysobjects (1) Yeah, its
access to a sql server C++ / VB hello ng how can I access to sql server with scripting host? I want read some user records and after write into the Active Directory. Thanks in advance for your help mark VBScript Discussions ADODB.Connection (1) SQL Server (1) Active Directory (1) CnctMSSQL (1) ADODB (1) SSQL (1) VbCrLf (1) CreateObject (1) Walser
VB6? If so how? Is there some sample code? TIA Sam VB DataBase ADO Discussions ADODB.Connection (1) SQL Server 2005 (1) SQL Server (1) Visual Studio (1) Surface (1) MyConn.Execute (1) MyConn.Close (1) ADODB (1) Sure examples in all of my Hitchhiker Guide books. Basically, you can create and execute an SQL query that includes the CREATE PROCEDURE call. I don't think the VB6 IDE itself could create a stored procedure, but there are lots of other tools that will. SQL Server Enterprise Manager can and so can SQL Server Management Studio (there's even a
Anybody used VB6 with SQL Server Compact Edition C++ / VB Hi Does anybody know how to create a db and link up with it using VB6? Thanks VB DataBase ADO Discussions SQL Server 2005 (1) SQL Server (1) Visual Studio 2008 (1) Database (1) ECUhl0R (1) SQLite (1) SqlCe (1) EBook (1 ADO-dependencies, only two small Dlls). Olaf Are you sure you are talking about the "SQL Server Compact Edition"? The CE version is part of a long line of MS SQLServer "Lite