SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Count the row
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

abhijaiswal.84
Starting Member

India
29 Posts

Posted - 05/30/2012 :  02:32:53  Show Profile  Reply with Quote
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

India
47157 Posts

Posted - 05/30/2012 :  16:35:37  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 05/31/2012 :  00:38:04  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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

India
29 Posts

Posted - 05/31/2012 :  02:02:35  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 05/31/2012 :  03:29:49  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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

Sweden
29138 Posts

Posted - 05/31/2012 :  04:31:21  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

India
29 Posts

Posted - 05/31/2012 :  05:44:23  Show Profile  Reply with Quote
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

India
47157 Posts

Posted - 05/31/2012 :  16:15:01  Show Profile  Reply with Quote
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

India
22461 Posts

Posted - 06/04/2012 :  08:49:33  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000