' **********************************************************' 定義テキスト取得' **********************************************************
Server = "$SERVER"
Db = "$DATABASE"
User = "$USER"
Pass = "$PASS"
ListTable = "$LISTTABLE"
List = Split( ListTable, "," )
Dim objServer,objDatabase,objTable
' **********************************************************' オブジェクト作成' **********************************************************
on error resume next
Set objServer = CreateObject("SQLDMO.SQLServer")
if Err.Number <> 0 then
Wscript.Echo "SQL-DMO はインストールされていません"
Wscript.Quit
end if
on error goto 0
' **********************************************************' 接続' **********************************************************
on error resume next
Call objServer.Connect( Server, User, Pass )
if Err.Number <> 0 then
Wscript.Echo "接続に失敗しました [" & Err.Description & "]"
Wscript.Quit
end if
on error goto 0
' **********************************************************' データーベースオブジェクト取得' **********************************************************
on error resume next
Set objDatabase = objServer.Databases(Db)
if Err.Number <> 0 then
Wscript.Echo Err.Description
Wscript.Quit
end if
on error goto 0
' **********************************************************' テーブルオブジェクト' **********************************************************
on error resume next
For i = 0 to Ubound( List )
Set objTable = objDatabase.Tables(List(i))
if Err.Number <> 0 then
Wscript.Echo Err.Description
Wscript.Quit
end if
strDrop = "if exists(select * from sysobjects where name = '"
strDrop = strDrop & objTable.Name & "'" & " and type = 'U')" & vbCrLf
strDrop = strDrop & " drop table " & objTable.Name & vbCrLf
strDrop = strDrop & "go" & vbCrLf
Wscript.Echo strDrop
Wscript.Echo objTable.Script()
Set objTable = Nothing
objTable = Empty
Next
on error goto 0
' **********************************************************' 切断' **********************************************************
Call objServer.DisConnect()