圆月山庄资源网 Design By www.vgjia.com
复制代码 代码如下:
set arg=wscript.arguments
If arg.count = 0 Then
show_help()
wsh.quit
End If
Server = arg(0)
User = arg(1)
pass = arg(2)
database_name = arg(3)
table_name = arg(4)
set Conn = CreateObject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=" & Server & ";UID=" & User & ";PWD=" & Pass & ";Database=" & database_name
Set rs = conn.execute("select count(*) as n from " & database_name & ".dbo.sysobjects where id = object_id(N'[dbo].[" & table_name & "]')")
if rs("n") <=0 Then
wsh.echo "table have???"
wsh.quit
End If
sql1="use " &database_name & ";select count(column_name) from information_schema.columns where table_name='" & table_name & "'"
set rs1=conn.execute(sql1)
num = rs1(0)
rs1.close
Set rs1 = Nothing
i = 1
sql2="use " &database_name & ";select column_name,data_type,IS_NULLABLE,character_octet_length,collation_name,domain_name from information_schema.columns where table_name='" & table_name & "' order by ordinal_position"
'wsh.echo sql2
set rs2=conn.execute (sql2)
wsh.echo "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" & table_name & "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)"
wsh.echo "drop table [dbo].[" & table_name & "]"
wsh.echo "GO"
wsh.echo "CREATE TABLE [dbo].[" & table_name & "] ("
do while not rs2.eof
col_dn = rs2("domain_name")
col_name = rs2("column_name")
col_type = rs2("data_type")
col_len = rs2("character_octet_length")
col_an = rs2("collation_name")
col_is = rs2("IS_NULLABLE")
sql = chr(9)&"[" & col_name & "] "
If col_dn = "id" Then
sql = sql & col_dn &" "
Else
sql = sql & "[" & col_type & "] "
If col_len <> "" Then
sql = sql & "(" & col_len & ") "
End If
If col_an <> "" Then
sql = sql & "COLLATE " & col_an
End If
End If
If col_is = "No" Then
sql = sql & " NOT NULL "
Else
sql = sql & " NULL "
End If
If i = num Then
sql = sql & Chr(13)&Chr(10)&") ON [PRIMARY]"
Else
sql = sql & ","
End If
i = i +1
wsh.echo sql
rs2.movenext
loop
wsh.echo "GO"
rs2.close
Set rs2 = Nothing
conn.close
Set conn=Nothing
Sub show_help()
wsh.echo "code by N37P47ch "
wsh.echo "cscript show_table.vbs ip user pass database table"
End Sub
set arg=wscript.arguments
If arg.count = 0 Then
show_help()
wsh.quit
End If
Server = arg(0)
User = arg(1)
pass = arg(2)
database_name = arg(3)
table_name = arg(4)
set Conn = CreateObject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=" & Server & ";UID=" & User & ";PWD=" & Pass & ";Database=" & database_name
Set rs = conn.execute("select count(*) as n from " & database_name & ".dbo.sysobjects where id = object_id(N'[dbo].[" & table_name & "]')")
if rs("n") <=0 Then
wsh.echo "table have???"
wsh.quit
End If
sql1="use " &database_name & ";select count(column_name) from information_schema.columns where table_name='" & table_name & "'"
set rs1=conn.execute(sql1)
num = rs1(0)
rs1.close
Set rs1 = Nothing
i = 1
sql2="use " &database_name & ";select column_name,data_type,IS_NULLABLE,character_octet_length,collation_name,domain_name from information_schema.columns where table_name='" & table_name & "' order by ordinal_position"
'wsh.echo sql2
set rs2=conn.execute (sql2)
wsh.echo "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" & table_name & "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)"
wsh.echo "drop table [dbo].[" & table_name & "]"
wsh.echo "GO"
wsh.echo "CREATE TABLE [dbo].[" & table_name & "] ("
do while not rs2.eof
col_dn = rs2("domain_name")
col_name = rs2("column_name")
col_type = rs2("data_type")
col_len = rs2("character_octet_length")
col_an = rs2("collation_name")
col_is = rs2("IS_NULLABLE")
sql = chr(9)&"[" & col_name & "] "
If col_dn = "id" Then
sql = sql & col_dn &" "
Else
sql = sql & "[" & col_type & "] "
If col_len <> "" Then
sql = sql & "(" & col_len & ") "
End If
If col_an <> "" Then
sql = sql & "COLLATE " & col_an
End If
End If
If col_is = "No" Then
sql = sql & " NOT NULL "
Else
sql = sql & " NULL "
End If
If i = num Then
sql = sql & Chr(13)&Chr(10)&") ON [PRIMARY]"
Else
sql = sql & ","
End If
i = i +1
wsh.echo sql
rs2.movenext
loop
wsh.echo "GO"
rs2.close
Set rs2 = Nothing
conn.close
Set conn=Nothing
Sub show_help()
wsh.echo "code by N37P47ch "
wsh.echo "cscript show_table.vbs ip user pass database table"
End Sub
标签:
SQL,表结构,vbs
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
更新日志
2024年11月01日
2024年11月01日
- 外媒:《死亡岛2》或是今年PS+2档最受欢迎游戏
- 群星.1997-世纪之歌第二辑6CD【宝丽金】【WAV+CUE】
- 邵萱.1997-是是非非【捷登】【WAV+CUE】
- 巫启贤.1998-我是你的【风格】【WAV+CUE】
- 【原神手游】「月草的赐慧」祈愿
- 【原神手游】「赤团开时」祈愿
- 【原神手游】「法器·千夜浮梦」介绍
- 陈立农《青春为名 上部曲 - 恋》[FLAC/分轨][290.58MB]
- 张乔西《明星》[320K/MP3][55.23MB]
- 张乔西《明星》[FLAC/分轨][143.08MB]
- 《P3R:Episode Aegis》:重复爬塔的悲伤
- 《公会传说:遗落的世界》EA版评测:怀旧感CRPG还在追我
- 诛仙老玩家会喜欢《诛仙世界》吗?
- ABC唱片-《母帶直刻神奇黑胶CD》[FLAC+CUE]
- 柏菲·李一凤《真爱过关》限量开盘母带ORMCD[低速原抓WAV+CUE]