Author |
Topic |
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2007-04-05 : 03:16:30
|
Hi all,I want to know 3 ways to get an accurate count of the number of records in a table Using query analyzer?i know only one i,eselect count(*) from tablenamewhat are the remaining 2 waysi am beginner to sql server,any help ll be appreciated. Thank's in advance |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-05 : 03:26:00
|
this is the only other way that i know will give accurate countselect * from tablenameselect @@rowcount KH |
|
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2007-04-05 : 03:29:20
|
but it ll list all the records first,i want the count only |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-05 : 03:42:04
|
Why do you need 3 ways to get accurate count of records in a table ?Is this some sort of quiz or interview question ? KH |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-05 : 03:48:47
|
1) select sum(1) from table12) select count(*) from table13) update table1 set col1 = col1; select @@rowcountPeter LarssonHelsingborg, Sweden |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-05 : 03:56:20
|
quote: Originally posted by Peso 1) select sum(1) from table12) select count(*) from table13) update table1 set col1 = col1; select @@rowcountPeter LarssonHelsingborg, Sweden
Good one KH |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-05 : 04:11:17
|
quote: Originally posted by Peso 1) select sum(1) from table12) select count(*) from table13) update table1 set col1 = col1; select @@rowcountPeter LarssonHelsingborg, Sweden
4 sp_spaceused table15 Select rows from sysindexes where id=object_id('table1')where indid<2Provided DBCC Updateusage is RunMadhivananFailing to plan is Planning to fail |
|
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2007-04-05 : 05:52:14
|
Thank's Peso and Madhivanan |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-05 : 09:00:42
|
Are 4) and 5) accurate?Peter LarssonHelsingborg, Sweden |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-05 : 23:46:57
|
quote: Originally posted by Peso Are 4) and 5) accurate?Peter LarssonHelsingborg, Sweden
YesProvided DBCC Updateusage is Run MadhivananFailing to plan is Planning to fail |
|
|
Ranjay Kumar
Starting Member
3 Posts |
Posted - 2014-11-18 : 03:52:52
|
SELECT * FROM table1SELECT COUNT(*) FROM table1SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2sp_spaceused 'Table Name'select @@rowcount from 'Table name'ranjay |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2014-11-26 : 03:31:27
|
quote: Originally posted by Ranjay Kumar SELECT * FROM table1SELECT COUNT(*) FROM table1SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2sp_spaceused 'Table Name'select @@rowcount from 'Table name'ranjay
Looks like you have just posted answers already providedMadhivananFailing to plan is Planning to fail |
|
|
|