MS SQL Server Concepts and Programming Question:
Download Questions PDF

How To Count Rows with the COUNT(*) Function in MS SQL Server?

Answer:

If you want to count the number of rows, you can use the COUNT(*) function in the SELECT clause. The following tutorial exercise shows you some good examples:

SELECT COUNT(*) FROM ggl_links
GO
7

SELECT COUNT(*) FROM ggl_links
WHERE url LIKE '%glo%'
GO
3

So there are 7 rows in total in table "ggl_links", and 3 rows that have 'glo' as part of their url names.

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How To Sort Query Output in Descending Order in MS SQL Server?Can SELECT Statements Be Used on Views in MS SQL Server?