主页 > 知识库 > SQL获取表结构的show_table.vbs (冰点极限NP)

SQL获取表结构的show_table.vbs (冰点极限NP)

热门标签:办理胶州400电话财税 前锋办理400电话申请 陕西高频外呼回拨系统哪家好 加盟电销机器人好的品牌 外呼营销下单系统 百度地图标注怎么卸载 海外美发店地图标注 新密防封卡外呼系统违法吗 打电话的外呼系统贵不贵
复制代码 代码如下:

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
您可能感兴趣的文章:
  • show engine innodb status显示信息不全如何解决
  • Oracle中实现MySQL show index from table命令SQL脚本分享
  • Mysql中 show table status 获取表信息的方法

标签:咸阳 四平 梅州 阜阳 牡丹江 伊春 武威 河南

巨人网络通讯声明:本文标题《SQL获取表结构的show_table.vbs (冰点极限NP)》,本文关键词  SQL,获取,表,结构,的,show,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《SQL获取表结构的show_table.vbs (冰点极限NP)》相关的同类信息!
  • 本页收集关于SQL获取表结构的show_table.vbs (冰点极限NP)的相关信息资讯供网民参考!
  • 推荐文章