Tuesday, December 4, 2007

How to use ASP to retrieve System Objects in MSSQL Server How to use ASP to retrieve System Objects in MSSQL Server How to use ASP to retrieve System

How to use ASP to retrieve System Objects in MSSQL Server

To use ASP to retrieve System Objects in MSSQL Server

Because MSSQL store tables and column information in its table called syscolumns and sysobjects, it would be great if you can explore these tables without modifying it.

An example of ASP code to retrieve system objects stored here is

strSQL = "SELECT syscolumns.name, syscolumns.type, syscolumns.length, " & _

"syscolumns.isnullable FROM sysobjects " & _

"INNER JOIN syscolumns ON sysobjects.id = syscolumns.id " & _

"where sysobjects.name = '" & strTableName & _

"' ORDER BY syscolumns.colid"

Set objRS = Server.CreateObject("ADODB.Recordset")

objRS.Open strSQL, objConn

do while <> objRS.eof

response.write(" Name " & objRs("name") & " objRs("length") & " Allow Null" & " objRs("isnullable" & " ")

response.write("
")

loop

No comments: