需要了解此代码吗? [英] Need to know about this code?

查看:90
本文介绍了需要了解此代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private int getCount()
{
    // This select statement is very fast compare to SELECT COUNT(*)
    string strSql = "SELECT Rows FROM SYSINDEXES " +
                    "WHERE Id = OBJECT_ID('tblEmp') AND IndId < 2";
    int intCount = 0;

    SqlCommand cmd = this.mcnSample.CreateCommand();
    cmd.CommandText = strSql;

    intCount = (int) cmd.ExecuteScalar();
    cmd.Dispose();

    return intCount;
}




有人可以建议我什么是SYSINDEXE和Object_ID..

或可以有人向我解释此查询




hi can any one suggest me what is SYSINDEXEs and Object_ID..

or can any one explain me about this query

string strSql = &quot;SELECT Rows FROM SYSINDEXES &quot; +
                  &quot;WHERE Id = OBJECT_ID(&#39;tblEmp&#39;) AND IndId &lt;




谢谢你.
此查询来自此artical
DataGrid分页-C#Windows表单 [




thank u.
this query from this artical
DataGrid Paging - C# Windows Forms[^]

推荐答案

SYSINDEXES视图包含SQL中所有索引的列表.实际上,这是一种访问此信息的折旧方法.现在我们改用DMV.不过,这就是您在SQL 2000中所做的. OBJECT_ID函数获取指定表的ID号.这是您在SYSINDEXES视图中查找所需表的方式. SQL语句的最终结果是,您将获得已应用于指定表的所有索引.

SYSINDEXES:
http://msdn.microsoft.com/en-us/library/ms190283.aspx [ ^ ]

OJBECT_ID: http://msdn.microsoft.com/en-us/library/ms190328.aspx [ ^ ]
The SYSINDEXES view contains a list of all of the indexes in SQL. This is actually a depreciated way of accessing this information. Now we use the DMV instead. This was how you did it in SQL 2000 though. The OBJECT_ID function gets the id number for the table specified. This is how you look up in the SYSINDEXES view the table you want. The end result of your SQL statement is that you will get all of the indexes that have been applied to the table you specified.

SYSINDEXES: http://msdn.microsoft.com/en-us/library/ms190283.aspx[^]

OJBECT_ID: http://msdn.microsoft.com/en-us/library/ms190328.aspx[^]


SysIndex:
http://msdn.microsoft.com/en-us/library/aa260413 (v = sql.80).aspx [ http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=107385 [ ^ ]


对象ID:
http://msdn.microsoft.com/en-us/library/ms190328.aspx [ ^ ]

在此查询中,作者希望使用其ID为特定数据库对象选择聚集索引详细信息.
SysIndex :
http://msdn.microsoft.com/en-us/library/aa260413(v=sql.80).aspx[^]

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=107385[^]


Object ID :
http://msdn.microsoft.com/en-us/library/ms190328.aspx[^]

In this query author want to select Clustered index details for a particular Database Object using its Id.


这篇关于需要了解此代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆