Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB;server=servername;database=msdb;uid=sa;password=password"
Set objRecordSet = CreateObject("ADODB.Recordset")
objRecordSet.Open "SELECT * FROM sysjobs", objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
'excel output
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
'chane field name for which column you dump
X=1
Do Until objRecordSet.EOF
objExcel.Cells(x, 1).Value = objRecordSet.Fields("name").Value
objRecordSet.MoveNext
x=x+1
Loop
'XML output
'objRecordSet.Save "output.xml" , adPersistXML
'Number of record
'Wscript.Echo objRecordSet.RecordCount
'Wscript.Echo objRecordSet.Fields("name").Value
'Close connection
objRecordSet.Close
objConnection.Close
Wednesday, 22 August 2007
Script for dumping information from Mssql tables
(select from top to end of script , copy and paste to your editor)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment