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 |
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2011-05-31 : 00:41:45
|
| Why "SELECT COUNT(*)" returns 1.what is the means?Thanksjs.reddy |
|
|
nirangava
Starting Member
4 Posts |
Posted - 2011-05-31 : 00:51:49
|
| if u run the querry like this it shuld get the row count of that table. if it's return 1 it means this table contains only one row. |
 |
|
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2011-05-31 : 00:55:45
|
| Hi nirangava, thank you for your response.But my query look like:SELECT COUNT(*)i didn't specify table name. |
 |
|
|
nirangava
Starting Member
4 Posts |
Posted - 2011-05-31 : 02:59:55
|
| oho... got the point. |
 |
|
|
Bazalddo
Starting Member
22 Posts |
Posted - 2011-05-31 : 07:00:58
|
| Hi js.reddy,In this case the count function counts whatever is bewteen the brackets, you could specify COUNT('Apple') and it will return 1. This is because there is one word in the box, just like if you have a asterisk in the box. It makes no difference.Hope this helpsBazShahbaz AhdiApps DeveloperODEON/UCI Cinema |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-06-01 : 11:10:06
|
| Slightly off topic butSELECT rows FROM sysindexes WHERE id = OBJECT_ID('MyTable') AND indid < 2gives same result as select count(*) from MyTable without doing a table scan |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-06-01 : 17:08:53
|
quote: Originally posted by lappin Slightly off topic butSELECT rows FROM sysindexes WHERE id = OBJECT_ID('MyTable') AND indid < 2gives same result as select count(*) from MyTable without doing a table scan
Not always. If you need a truly accurate count you need to go to the table directly. System metadata objects are not 100% accurate. |
 |
|
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-06-02 : 06:47:58
|
| I've read a lot of opinions on this but I haven't seen anything definitive. Some people say it is dependent on statistics being up to date - but is this documented?rows in sys.sysindexes is defined as "Data-level row count"http://technet.microsoft.com/en-us/library/ms190283(SQL.110).aspx |
 |
|
|
|
|
|