新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     >>W3CHINA.ORG讨论区<<     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> Oracle, SQL Server与XML,XML在数据挖掘中的应用, PMML.
    [返回] W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWLXML.ORG.CN讨论区 - 高级XML应用『 XML 与 数据库 』 → SQL SERVER结构浏览器 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2703 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: SQL SERVER结构浏览器 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     niekui 帅哥哟,离线,有人找我吗?双鱼座1987-3-2
      
      
      等级:大一(高数修炼中)
      文章:16
      积分:111
      门派:XML.ORG.CN
      注册:2005/3/2

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给niekui发送一个短消息 把niekui加入好友 查看niekui的个人资料 搜索niekui在『 XML 与 数据库 』的所有贴子 访问niekui的主页 引用回复这个贴子 回复这个贴子 查看niekui的博客楼主
    发贴心情 SQL SERVER结构浏览器

    从老外那儿转帖过来的

    很酷,只要修改几个参数就可以了,很有帮助

    <%@ 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;    
    %>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=<%=CharSet%>">
    <title>MS SQL Structure Viewer Version 1.2</title>
    </head>
    <body bgcolor=#2f2f2f link=#000000 vlink=#000000 alink=#000000 topmargin=1 leftmargin=1>
    <table width='100%' bgcolor=gray cellpadding=0 cellspacing=0><td>
    <table width='100%' cellpadding=0 cellspacing=1>
    <tr><td align=center>
        <font color=white size=+1><b>MS SQL WebTools &gt;&gt; Table Structure Viewer</b></font></td>
        <td align=right>
        <font color=black><small><b>written by
        <a href="mailto:little@ivc.tagmet.ru">
        <font color=black><small><b>Alexander Tkalich</b></small></a></b></small></font>
    </td></tr>
    </table>
    </td>
    </table>
    <p>
    <%
    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( "<select name='"+ Name+ "' size="+ SSize+ ">");
        if( FirstName!= "")
            Response.Write( "<option value='"+ FirstValue+ "'>"+ FirstName);
        for( ; !Rs.EOF; Rs.MoveNext()){
            Id= Rs( 0);
            Nm= Rs( 1);
            if( Value== ""+ Id) S= 'selected'; else S= ';
            Response.Write( "<option value='"+ Id+ "' "+ S+ ">"+ Nm+ " ");
        }
        Response.Write( "</select>");
    }

    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;
    %>

    <center>

    <%
    var Conn= Server.CreateObject("ADODB.Connection");
    Conn.Open( ConnStr, UserLogin, UserPassword);

    if( !isDef( Tbl)){
    %>

    <form name='f' method=post action='TbStru.asp'>
    <input type=hidden name=CurrentDb value='<%=DbName%>'>
    <table border=1 bgcolor=#7f9faf cellpadding=0 cellspacing=0><td>
    <table border=0 cellpadding=8 cellspacing=0><tr valign=bottom><td align=center><b>Databases</b><br>

    <%
        QOutSelect( Conn, "DbName' onChange='document.f.submit();", DbName, "", "",
            "select name, name from master.dbo.sysdatabases Order by name", 10);
        Response.Write( '</td>');
        if( isDef( DbName)){
            Response.Write( '<td align=center><b>Tables & Views</b><br>');
            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( '</td>');
        }
        if( isDef( DbName)) S= 'Show structure';
        else S= 'Show list of tables';
        Response.Write(
            " <td><table height='100%' border=0> "+
            "<tr valign=bottom><td><input type=submit value='"+ S+ "'></td></tr> "+
            "</table></td></tr></table></td></table></form><p> "
        );
    }

    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(
            "<a target='_blank' href='TbStru.asp?Tbl=["+ DbName+ "].["+ TbOwner+ "].["+ TbName+ "]&TbId="+ TbId+
            "&DbName="+ DbName+ "'>"+
            "<font color=white><b>"+ DbName+ "."+ TbOwner+ "."+ TbName+ "</b></font></a> "
        );
        Response.Write( "<br> ");
        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)+ '"+
                    ""><b>'+ O.name+ '</b></a>'"+
                    " 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"
        );
    %>
        <input type=hidden name=DbName value='<%=DbName%>'>
        <input type=hidden name=CurrentDb value='<%=DbName%>'>
        <input type=hidden name='TbId' value='<%=TbId%>'>
        <table border=1 bordercolor=#5f5f5f bgcolor=#cfcfcf cellpadding=3 cellspacing=0>
        <tr bgcolor=<%=trColor%>><th>Nn</th><th>Name</th><th>Type</th><th>length</th>
            <th>precision</th><th>scale</th><th>default value</th><th>properties</th><th>relation</th></tr>
    <%
        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><b><%=i%></b></td><td>&nbsp;
            <%=Rs( 0)%></td>
            <td align=right>&nbsp;<%=Rs( 1)%></td>
            <td align=right>&nbsp;<%=Rs( 2)%></td>
    <%
            if( Rs( 1)== 'numeric'|| Rs( 1)== 'decimal'){
                prec= Rs( 3);
                scale= Rs( 4);
            } else prec= scale= '&nbsp;';
            colstat= "";
            if( Rs( 7)== 1) colstat+= ", Identity";
            if( Rs( 5)== 1) colstat+= ", Primary Key";
            if( Rs( 6)== 1) colstat+= ", Nullable";
            if( colstat== "")
                colstat= "&nbsp;";
            else
                colstat= colstat.substring( 2);
            cdefault= Rs( 8);
            if( !isDef( cdefault)) cdefault= "&nbsp;";
            else {
                cdefault= ""+ cdefault;
                cdefault= cdefault.substring( 1, cdefault.length- 1);
            }
            foreign= Rs( 9);
            if( !isDef( foreign)) foreign= "&nbsp;";
    %>
            <td align=right><%=prec%></td><td><%=scale%></td>
            <td><%=cdefault%></td><td><%=colstat%></td><td><%=foreign%></td>
            </tr>
    <%
        }
    %>
        </table>
    <%
    }
    if( isDef( Tbl)){
        Response.Write( "<font color=white><b>"+ Tbl+ "</b></font></a><br> ");
        Rs= Conn.Execute( "select count( *) from "+ Tbl);
        RecordCount= Rs( 0);
        Response.Write( "<font color=white>"+ RecordCount+ " Records total</font><br>");
        Rs= Conn.Execute( "select * from "+ Tbl);
        if( !isDef( Row))
            Row= 0;
        if( !Rs.EOF)
            Rs.Move( Row);
    %>
    <table bgcolor=#9fbfcf border=1 cellpadding=1 cellspacing=0><tr bgcolor=#cfcfcf><th>N/n</th>
    <%
        var ColCount= Rs.Fields.Count;
        for( i1= 0; i1< ColCount; i1++)
            Response.Write( "<th>"+ Rs.Fields( i1).Name+ "</th>");
        Response.Write( "</tr> ");
        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><b><%=i%></b></td>
    <%
            for( i1= 0; i1< ColCount; i1++)
                Response.Write( "<td>"+ Rs.Fields( i1).Value+ "</td>");
            Response.Write( "</tr> ");
        }
        if( Cntr> 0){
            Response.Write( "<tr bgcolor=#cfcfcf><th>N/n</th>");
            for( i1= 0; i1< ColCount; i1++)
                Response.Write( "<th>"+ Rs.Fields( i1).Name+ "</th>");
            Response.Write( "</tr> ");
        }
        Response.Write( "</table> <table width='50%' border=0>");
        if( Prev>= 0){
            QS= new String( Request.QueryString);
            Prev= QS.substring( 0, QS.lastIndexOf( "=")+ 1)+ Prev;
            Response.Write( "<td><a href='TbStru.asp?"+ Prev+ "'><font color=white><b>&lt;&lt; Previous</a>&nbsp;&nbsp;&nbsp;</b></font></td> ");
        }
        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( "<td align=right><a href='TbStru.asp?"+ Next+ "'><font color=white><b>Next &gt;&gt;</b></font></a></td> ");
        }
        Response.Write( "</table>");
    }
    %>



      
      


       


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/4/14 15:41:00
     
     GoogleAdSense双鱼座1987-3-2
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XML 与 数据库 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/11/27 11:30:07

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    78.125ms