Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-12-04 : 01:40:58
|
| Dear All,based on objectid column in sysindexes, how to know the table name?select object_name(id) as table_name, rows from sysindexeswhere indid<2 order by rows descactually i'm trying to replace the query select count(*) from mytablewith select object_name(id) as table_name, rows from sysindexeswhere indid<2 queryplease guide meVinodEven you learn 1%, Learn it with 100% confidence. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-04 : 01:48:32
|
| What did the following give?select object_name(id) as table_name, rows from sysindexeswhere indid<2 order by rows descMadhivananFailing to plan is Planning to fail |
 |
|
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-12-04 : 01:58:55
|
| select rows from sysindexeswhere indid<2 and object_name(id)='mytable23'yes i got the desired out put.thank you madhi....but i still got doubt how it indid taking the data......VinodEven you learn 1%, Learn it with 100% confidence. |
 |
|
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-12-04 : 02:00:30
|
| and actually one row less it is showing..select count(*) is giving 623and this one is giving 622VinodEven you learn 1%, Learn it with 100% confidence. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-04 : 02:08:40
|
| dbcc updateusage ('dbname','mytable23') with count_rowsselect rows from sysindexeswhere indid<2 and object_name(id)='mytable23'MadhivananFailing to plan is Planning to fail |
 |
|
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-12-04 : 02:17:31
|
| Thank you Madhi,now it is working fine.....actually i'm tuning stored procedures and functions in my application.can i replace select count(*) from my table query with the above query? will it give the same result? or i need to use the DBCC command everytime? suggest me please....and will it really better replacing count (*) with the above query......and i'm planning to replace IN with EXISTS at each and every procedure and function.as well as cursor with set based sql(i'l take guidence for all these things)please guide me in this regardthanks a lot for your helpVinodEven you learn 1%, Learn it with 100% confidence. |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-12-04 : 08:31:29
|
if your count must be 100% accurate 100% of the time, you should use count(*)if 100% accuracy is not needed, sysindexes is ok. elsasoft.org |
 |
|
|
|
|
|
|
|