从老外那儿转帖过来的
很酷,只要修改几个参数就可以了,很有帮助
<%@ language="JScript">
<%
var ConnStr= "DSN=admin"; //
var UserLogin= "sa"; // input empty Login and Password,
var UserPassword= ""; // if your DSN works via WinNT trust connection
var CharSet= "gb2312"; // as sample "windows-1251"
var PgSize= 10;
%>
">
MS SQL Structure Viewer Version 1.2
MS SQL WebTools >> Table Structure Viewer | written by Alexander Tkalich |
<%
var trColor1= "#7f9faf", trColor2= "#bfcfd7";
var trColor= trColor1;
function isDef( Value){
if( Value== ( Value+ "")) return true;
return false;
}
function QOutSelect( Conn, Name, Value, FirstName, FirstValue, SQL, SSize){
var Rs= Conn.Execute( SQL);
Response.Write( ""); if( FirstName!= "") Response.Write( ""+ FirstName); for( ; !Rs.EOF; Rs.MoveNext()){ Id= Rs( 0); Nm= Rs( 1); if( Value== ""+ Id) S= 'selected'; else S= ''; Response.Write( ""+ Nm+ "\n"); } Response.Write( "");
}
var S, DbName, TbName, Tbl, Row;
if( !isDef( DbName= Request.Form( "DbName")))
DbName= Request.QueryString( "DbName");
if( !isDef( TbId= Request.Form( "TbId")))
TbId= Request.QueryString( "TbId");
Tbl= Request.QueryString( "Tbl");
Row= Request.QueryString( "Row")/ 1;
%>
<%
var Conn= Server.CreateObject("ADODB.Connection");
Conn.Open( ConnStr, UserLogin, UserPassword);
if( !isDef( Tbl)){
%>
">
');
if( isDef( DbName)){
Response.Write( '');
}
if( isDef( DbName)) S= 'Show structure';
else S= 'Show list of tables';
Response.Write(
"\n\n"+
"
Databases <% QOutSelect( Conn, "DbName' onChange='document.f.submit();", DbName, "", "", "select name, name from master.dbo.sysdatabases Order by name", 10); Response.Write( ' | Tables & Views '); QOutSelect( Conn, "TbId' onChange='document.f.submit();", TbId, '', '', "select id, name from "+ DbName+ ".dbo.sysobjects where type in ('U','V') and category<>2 Order By Name", 10); Response.Write( ' | \n"+ " |
\n"
);
}
if( !isDef( CurrentDb= Request.Form( "CurrentDb")))
CurrentDb= Request.QueryString( "CurrentDb");
if( !isDef( Tbl)&& isDef( DbName)&& DbName+ ""== CurrentDb+ ""&& isDef( TbId)){
Rs= Conn.Execute(
"select O.name, U.name"+
" from "+ DbName+ ".dbo.sysobjects O, "+
DbName+ ".dbo.sysusers U"+
" where O.id="+ TbId+ " and U.uid=O.uid"
);
TbName= Rs( 0);
TbOwner= Rs( 1);
Response.Write(
""+
""+ DbName+ "."+ TbOwner+ "."+ TbName+ "\n"
);
Response.Write( "
\n");
Rs= Conn.Execute(
"select C.name, T.name, C.length, C.xprec, C.xscale,"+
" C.colstat, C.isnullable,"+
" case when C.autoval is null then 0 else 1 end,"+
" SC.text, "+
"( select CForgin.name+ ' of '+ '<a href=\"TbStru.asp?"+
"DbName="+ DbName+ "&CurrentDb="+ DbName+
"&TbName='+ O.name+ '&TbId='+ Convert( varchar, Sr.rkeyid)+ '"+
"\">'+ O.name+ ''"+
" from "+ DbName+ ".dbo.sysreferences Sr,"+
DbName+ ".dbo.sysobjects O,"+
DbName+ ".dbo.syscolumns CForgin"+
" where Sr.fkeyid="+ TbId+ " and Sr.fkey1=C.colid and Sr.rkeyid=O.id"+
" and CForgin.id=O.id and CForgin.colid=Sr.rkey1"+
") from "+ DbName+ ".dbo.syscolumns C, "+
DbName+ ".dbo.systypes T, "+
DbName+ ".dbo.syscomments SC "+
"where C.id="+ TbId+ " and C.xtype=T.xusertype and C.cdefault*=SC.id "+
"order by C.colid"
);
%>
">
">
">
<tr bgcolor=<%=trcolor%>>
<%
for( TrColor= '', i= 1; !Rs.EOF; i++, Rs.MoveNext()){
if( trColor== trColor1) trColor= trColor2;
else trColor= trColor1;
%>
<tr bgcolor=<%=trcolor%>>
<td bgcolor=<%=trcolor2%>align=right><%=i%>
<%
if( Rs( 1)== 'numeric'|| Rs( 1)== 'decimal'){
prec= Rs( 3);
scale= Rs( 4);
} else prec= scale= ' ';
colstat= "";
if( Rs( 7)== 1) colstat+= ", Identity";
if( Rs( 5)== 1) colstat+= ", Primary Key";
if( Rs( 6)== 1) colstat+= ", Nullable";
if( colstat== "")
colstat= " ";
else
colstat= colstat.substring( 2);
cdefault= Rs( 8);
if( !isDef( cdefault)) cdefault= " ";
else {
cdefault= ""+ cdefault;
cdefault= cdefault.substring( 1, cdefault.length- 1);
}
foreign= Rs( 9);
if( !isDef( foreign)) foreign= " ";
%>
<%
}
%>
Nn | Name | Type | length | precision | scale | default value | properties | relation |
---|---|---|---|---|---|---|---|---|
<%=rs(> | <%=rs(> | <%=rs(> | <%=prec%> | <%=scale%> | <%=cdefault%> | <%=colstat%> | <%=foreign%> |
<%
}
if( isDef( Tbl)){
Response.Write( ""+ Tbl+ "
\n");
Rs= Conn.Execute( "select count( *) from "+ Tbl);
RecordCount= Rs( 0);
Response.Write( ""+ RecordCount+ " Records total
");
Rs= Conn.Execute( "select * from "+ Tbl);
if( !isDef( Row))
Row= 0;
if( !Rs.EOF)
Rs.Move( Row);
%>
<%
var ColCount= Rs.Fields.Count;
for( i1= 0; i1< ColCount; i1++)
Response.Write( "");
Response.Write( "\n");
Prev= Row- PgSize;
if( Prev< 0&& Row> 0) Prev= 0;
for( i= Row+ 1, Cntr= 0;
Cntr< PgSize&& !Rs.EOF;
Rs.MoveNext(), i++, Cntr++
){
if( trColor== trColor1) trColor= trColor2;
else trColor= trColor1;
%>
<tr bgcolor=<%=trcolor%>>
<td bgcolor=<%=trcolor2%>align=right><%=i%>
<%
for( i1= 0; i1< ColCount; i1++)
Response.Write( "");
Response.Write( "\n");
}
if( Cntr> 0){
Response.Write( "");
for( i1= 0; i1< ColCount; i1++)
Response.Write( "");
Response.Write( "\n");
}
Response.Write( "
N/n | "+ Rs.Fields( i1).Name+ " |
---|---|
"+ Rs.Fields( i1).Value+ " | |
N/n | "+ Rs.Fields( i1).Name+ " |
\n");
if( Prev>= 0){
QS= new String( Request.QueryString);
Prev= QS.substring( 0, QS.lastIndexOf( "=")+ 1)+ Prev;
Response.Write( "\n");
}
if( !Rs.EOF){
QS= new String( Request.QueryString);
if( QS.lastIndexOf( "&Row=")+ 1)
Next= QS.substring( 0, QS.lastIndexOf( "=")+ 1)+ ( i- 1);
else
Next= QS+ "&Row="+ ( i- 1);
Response.Write( "\n");
}
Response.Write( "
<< Previous | Next >> |
");
}
%>
相关视频
相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3
最新文章
微信3.6.0测试版更新了微信支付漏洞会造成哪
360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗
人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本
查看所有0条评论>>