A script to view the structure of the MS SQL Server table (originally intended for plagiarism)

Source: Internet
Author: User
Tags empty odbc table name
server| Script <%
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn.Open "ODBC name", "username", "password"



Sql1= "SELECT * from dbo.sysobjects where type is 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 as not rscc.eof


sql = "SELECT * from" &AMP;RSCC ("name")

Rs.Open sql,conn,1,2
Response.Write " Table name "&AMP;RSCC" ("Name") & "
"
If "1" = "1" Then
For i=0 to Rs. Fields.count-1

Response.Write "Field Name:" &rs.fields (i). Name &
"
Response.Write "Type:"
If Rs.fields (i) type= "3" Then
Response.Write "Int"
If Rs.fields (i). Attributes= "Then" Response.Write "AutoNumber field"
If Rs.fields (i). Attributes= "Then" Response.Write "Allow null"
If Rs.fields (i). Attributes= "then" Response.Write "Not allowed empty"
ElseIf Rs.fields (i) type= "129" Then
Response.Write "Char"
Response.Write "Size" &rs.fields (i). DefinedSize
If Rs.fields (i). Attributes= "Then" Response.Write "Allow null"
If Rs.fields (i). Attributes= "then" Response.Write "Not allowed empty"
ElseIf Rs.fields (i) type= "201" Then
Response.Write "Text"
If Rs.fields (i). attributes= "234" then Response.Write "Allow null"
If Rs.fields (i). attributes= "138" Then Response.Write "do not allow Nulls"
ElseIf Rs.fields (i) type= "then"
Response.Write "nvarchar"
Response.Write "Size" &rs.fields (i). DefinedSize
If Rs.fields (i). Attributes= "8" Then Response.Write "! Do not allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
ElseIf Rs.fields (i) type= "131" then
Response.Write "Numeric"
If Rs.fields (i). Attributes= "Then" Response.Write "Allow null"
If Rs.fields (i). Attributes= "then" Response.Write "Not allowed empty"
ElseIf Rs.fields (i) type= "2" Then
Response.Write "smallint"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
ElseIf Rs.fields (i) type= "one" then
Response.Write "Bit"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
ElseIf Rs.fields (i) type= "135" Then
Response.Write "SmallDateTime"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
ElseIf Rs.fields (i) type= "203" Then
Response.Write "ntext"
If Rs.fields (i). attributes= "234" Then Response.Write "! Allow null "
If Rs.fields (i). attributes= "138" Then Response.Write "! Do not allow null "
ElseIf Rs.fields (i) type= "6" Then
Response.Write "Money"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
ElseIf Rs.fields (i) type= "130" Then
Response.Write "NCHAR"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
ElseIf Rs.fields (i) type= "4" Then
Response.Write "Real"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
ElseIf Rs.fields (i) type= "5" Then
Response.Write "Flat"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
ElseIf Rs.fields (i) type= "128" Then
Response.Write "Binary"
If Rs.fields (i). Attributes= "Then Response.Write"! Allow null "
If Rs.fields (i). Attributes= "Then Response.Write"! Do not allow null "
Else
Response.Write "Unknown" &rs.fields (i). Type
End If

Response.Write "Properties:" &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 name", "username", "password"



Sql1= "SELECT * from dbo.sysobjects where type is 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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.