Viatcheslav
Sat Feb 07 03:30:17 CST 2004
Instead of using another process (isql), use ADO (this will not use any
files)
Dim conn, rs, strSELECT
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
strSELECT = "select " & _
"cast(substring(@@version,0,charindex('(',@@version,0)) as varchar(40)), "
& _
"cast(substring(@@version,charindex('Build',@@version,0)-1, Len(@@version))
" & _
"as varchar(35))"
conn.Open "Provider=SQLOLEDB;User ID=sa;Password=password;Initial
catalog=master;"
rs.Open strSELECT, conn
rs.MoveFirst
Dim strVersion, strSP
strVersion = rs(0)
strSP = rs(1)
rs.Close
conn.Close
WScript.Echo strVersion & " - " & strSP
rs.Close
conn.Close
//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com - best scripting/compiled HTA IDE
"Dragon" <NoSpam_Baadil@hotmail.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:eMDaA%23O7DHA.2540@TK2MSFTNGP11.phx.gbl...
> Hi Everyone,
>
> I am very new to VB Scripting and would like to find out how might I go
> about running an SQL (2000) statement through VBScript and then assign the
> result into an environment variable. My application can read the
environment
> variables. Essentially here is the SQL command I have been trying to use
> with VB Script:
>
> isql -U sa -P password -Q "select
> cast(substring(@@version,0,charindex('(',@@version,0)) as varchar(40)),
> cast(substring(@@version,charindex('Build',@@version,0)-1, Len(@@version))
> as varchar(35))" -o c:\result\SQLVersion.txt
>
> The SQL statement gives me the SQL Server version and its service pack
info.
> Right now it writes to a file but I rather keep it in the memory if
> possible, and then simply manipulate the text so that it shows only a
single
> line of text instead of three.
>
> Thank you for any pointers.
>
>