杰网资源 Design By www.escxy.com
获得SQL数据/日志空间使用,已使用的和未使用的空间的脚本

getSQLinfo.vbs
'script to get   SQL DATA/LOG Space Used, Space unused, 
and Space Free 
'Author: Felipe Ferreira, Daniel Magrini
'Date: 05/07/07
'Version 2,0

'@@TO CHANGE::: SERVERNAME\Instance, domain\user, password AND DATABSE!

'____________________________________________________________________________
Const ForReading = 1, ForWriting = 2, ForAppending = 8 
Set oFSO = CreateObject("Scripting.FilesyStemObject") 
outputfile = "CheckSqlDB_Size.txt" 
Set ofile = oFso.OpenTextFile(outputfile,8, True)
oFile.Writeline "######################################################"
oFile.Writeline "This command executed in " & Date & " at " & Time & VbCrLf
'____________________________________________________________________________

CheckSQLData
CheckSQLLOG


'############## GET SQL DATA SPACE USED, SPACE TOTAL, SPACE FREE
'Function checkSQL(strServer,strDB)   in the future make it a function....
Sub CheckSQLDATA
Const adOpenDynamic = 1, adLockOptimistic = 3
Dim strQuery
Dim objConnection, objRecordSet 
Dim strQueryResult, strQueryResult2
Dim UsedDataSpace, TotalDataSpace, FreeDataSpace
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
   "Provider=SQLOLEDB.1;Server=192.168.8.10;User ID=sa;Password=lcx;Database=master;"

strQuery = "DBCC showfilestats"
   objRecordSet.Open strQuery, objConnection, adOpenDynamic, adLockOptimistic
   if objRecordSet.eof Then
       'nothing returned
    wscript.echo "ERROR!!!"
   Else 

'NOTE : To get the value in MB   64 / 1024 = 0.0625
   Do Until objRecordSet.eof 
      strQueryResult = objRecordSet.Fields("UsedExtents")
    UsedDataSpace = strQueryResult * 0.0625
    strQueryResult2 = objRecordSet.Fields("TotalExtents")
    TotalDataSpace = strQueryResult2 * 0.0625
    FreeDataSpace = TotalDataSpace - UsedDataSpace

    'Clean Data
    UsedDataSpace = Left(UsedDataSpace,4)
    FreeDataSpace = Left(FreeDataSpace,4)
    TotalDataSpace = Left(TotalDataSpace,4)

    'Print Result on Screen
    Wscript.echo "Used Space(MB) = " & UsedDataSpace 
    Wscript.Echo "Free Space(MB) = " & FreeDataSpace
    Wscript.Echo "Total Space(MB) = " & TotalDataSpace

    'Write on File
    ofile.WriteLine "Used DATA Space(MB) = " & UsedDataSpace
    ofile.WriteLine "Free DATA Space(MB) = " & FreeDataSpace
    ofile.WriteLine "Total DATA Space(MB) = " & TotalDataSpace

      objRecordSet.MoveNext
   loop
   end if
objRecordSet.Close
objConnection.Close 
set objConnection = nothing
set objRecordSet = nothing
end sub

Sub CheckSQLLOG
Const adOpenDynamic = 1, adLockOptimistic = 3
Dim strQuery
Dim objConnection, objRecordSet 
Dim strQueryResult, strQueryResult2
Dim UsedLogSpace, TotalLogSpace, FreeLogSpace
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
   "Provider=SQLOLEDB.1;Server=192.168.8.10;User ID=sa;Password=lcx;Database=master;"

strQuery = "DBCC SQLPERF(LOGSPACE)"
   objRecordSet.Open strQuery, objConnection, adOpenDynamic, adLockOptimistic
   if objRecordSet.eof Then
       'nothing returned
    wscript.echo "ERROR!!!"
   Else 


   Do Until objRecordSet.eof 
    If objRecordSet.Fields("Database Name") = "master" Then

   
     strQueryResult = objRecordSet.Fields("Log Size (MB)")
     strQueryResult2 = objRecordSet.Fields("Log Space USed (%)")
     UsedLogSpace = (strQueryResult * strQueryResult2) / 100
     TotalLogSpace = strQueryResult
     FreeLogSpace = TotalLogSpace - UsedLogSpace

     'Clean Data
     UsedLogSpace = Left(UsedLogSpace,4)
     FreeLogSpace = Left(FreeLogSpace,4)
     TotalLogSpace = Left(TotalLogSpace,4)

     'Print Result on Screen
     Wscript.echo "Used Space(MB) = " & UsedLogSpace 
     Wscript.Echo "Free Space(MB) = " & FreeLogSpace
     Wscript.Echo "Total Space(MB) = " & TotalLogSpace

     'Write on File
     oFile.WriteLine "Used LOG Space(MB) = " & UsedLogSpace
     oFile.WriteLine "Free LOG Space(MB) = " & FreeLogSpace
     oFile.WriteLine "Total LOG Space(MB) = " & TotalLogSpace

     oFile.close

     Exit Do

    End If

      objRecordSet.MoveNext
   loop
   end if
objRecordSet.Close
objConnection.Close 
set objConnection = nothing
set objRecordSet = nothing
end sub
WSCript.Quit 

标签:
getSQLinfo,SQL数据

杰网资源 Design By www.escxy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
杰网资源 Design By www.escxy.com

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。