一個用來查看MS sql server表結構的一個指令碼(本來打算用來剽竊的)

來源:互聯網
上載者:User
server|指令碼 <%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "ODBC名","使用者名稱","密碼"



Sql1="select * from dbo.sysobjects where type not in('S','D','K')"
Sql1="select * from dbo.sysobjects where type ='U'"
set rscc = server.createobject("ADODB.recordset")
set rs = server.createobject("ADODB.recordset")
rscc.open sql1,conn,1,2

do while not rscc.eof


sql ="select * from "&RSCC("name")

rs.open sql,conn,1,2
response.write "表名"&RSCC("name")&"
"
if "1"="1" then
for i=0 to rs.Fields.Count-1

response.write "欄位名:"&rs.fields(i).name &"
"
response.write "類型:"
if rs.fields(i).type="3" then
response.write "int"
if rs.fields(i).Attributes="16" then response.write " 自動編號欄位"
if rs.fields(i).Attributes="120" then response.write " 允許空"
if rs.fields(i).Attributes="24" then response.write " 不允許空"
elseif rs.fields(i).type="129" then
response.write "char"
response.write "大小"&rs.fields(i).DefinedSize
if rs.fields(i).Attributes="120" then response.write " 允許空"
if rs.fields(i).Attributes="24" then response.write " 不允許空"
elseif rs.fields(i).type="201" then
response.write "text"
if rs.fields(i).Attributes="234" then response.write " 允許空"
if rs.fields(i).Attributes="138" then response.write " 不允許空"
elseif rs.fields(i).type="202" then
response.write "nvarchar"
response.write "大小"&rs.fields(i).DefinedSize
if rs.fields(i).Attributes="8" then response.write " ! 不允許空"
if rs.fields(i).Attributes="104" then response.write "! 允許空"
elseif rs.fields(i).type="131" then
response.write "numeric"
if rs.fields(i).Attributes="120" then response.write " 允許空"
if rs.fields(i).Attributes="24" then response.write " 不允許空"
elseif rs.fields(i).type="2" then
response.write "smallint"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
elseif rs.fields(i).type="11" then
response.write "bit"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
elseif rs.fields(i).type="135" then
response.write "smalldatetime"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
elseif rs.fields(i).type="203" then
response.write "ntext"
if rs.fields(i).Attributes="234" then response.write "! 允許空"
if rs.fields(i).Attributes="138" then response.write " ! 不允許空"
elseif rs.fields(i).type="6" then
response.write "money"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
elseif rs.fields(i).type="130" then
response.write "nchar"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
elseif rs.fields(i).type="4" then
response.write "real"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
elseif rs.fields(i).type="5" then
response.write "flat"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
elseif rs.fields(i).type="128" then
response.write "binary"
if rs.fields(i).Attributes="120" then response.write "! 允許空"
if rs.fields(i).Attributes="24" then response.write " ! 不允許空"
else
response.write "未知"&rs.fields(i).type
end if

response.write " 屬性:"&rs.fields(i).Attributes
response.write "-------------
"

next
end if
rs.close

'-------------------------------------
rscc.MoveNext
loop
set rs=nothing
set rscc=nothing

set conn=nothing
%><%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "ODBC名","使用者名稱","密碼"



Sql1="select * from dbo.sysobjects where type not in('S','D','K')"
Sql1="select * from dbo.sysobjects where type ='U'"
set rscc = server.createobject("ADODB.recordset")
set rs = server.createobject("ADODB.recordset")
rscc.open sql1,conn,1,2



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。