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.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Count the row

Author  Topic 

abhijaiswal.84
Starting Member

29 Posts

Posted - 2012-05-30 : 02:32:53
Hi,

Can anyone help me to findout the answer for,

How will you get count of rows from table except count?

THanks in advance.

Abhishek

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-30 : 16:35:37
what do you mean by count of rows from table except count ?



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-05-31 : 00:38:04
Select count(*) from tbl
Might be a start
Or sp_spaceused tbl

Try that and come back with anything else you want.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

abhijaiswal.84
Starting Member

29 Posts

Posted - 2012-05-31 : 02:02:35
I want the count of the records in a table (e.g. Select count (*) from TableName) but I dont want to use count keyword.

Without using "count" keywork how can we get the count of records from a table?

Abhishek
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-05-31 : 03:29:49
Why do you not want to use count? Anything else you don't want to use?
sp_spaceused will do it.
Can also use sysindexes or sys.partitions but that will require other keywords

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-31 : 04:31:21
BEGIN TRAN
DELETE FROM dbo.Table
SELECT @@ROWCOUNT
ROLLBACK TRAN




N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

abhijaiswal.84
Starting Member

29 Posts

Posted - 2012-05-31 : 05:44:23
I want to solve this query with some other ways, if we use any other keyword other than "Count" will also fine.

Abhishek
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-31 : 16:15:01
quote:
Originally posted by abhijaiswal.84

I want to solve this query with some other ways, if we use any other keyword other than "Count" will also fine.

Abhishek


looks like an interview question to me

other than that i cant see a reason for this requirement

SELECT SUM(1)
FROM table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-06-04 : 08:49:33
quote:
Originally posted by abhijaiswal.84

I want the count of the records in a table (e.g. Select count (*) from TableName) but I dont want to use count keyword.

Without using "count" keywork how can we get the count of records from a table?

Abhishek


http://beyondrelational.com/modules/2/blogs/70/posts/10817/different-ways-to-count-rows-from-a-table.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -