473,761 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Count Rows Help

1 New Member
Hi there, I'm a SQL Server 2000 noob and looking for some help.

I need to make a simple script that counts the number of rows in a table.

Also, i need to make another version ofthe same script, but ONLY look and count rows with certain data in them...e.g. search and count for rows with the word JOE in them.

Any help would be really appreciated, and if somebody would be so kind to break down and explain each part of the script i would be VERY grateful.

Cheers,
Deja.
May 16 '07 #1
1 1590
pradeep kaltari
102 Recognized Expert New Member
Hi there, I'm a SQL Server 2000 noob and looking for some help.

I need to make a simple script that counts the number of rows in a table.

Also, i need to make another version ofthe same script, but ONLY look and count rows with certain data in them...e.g. search and count for rows with the word JOE in them.

Any help would be really appreciated, and if somebody would be so kind to break down and explain each part of the script i would be VERY grateful.

Cheers,
Deja.
Hi Deja,
To find out the number of rows in a given table you can use:
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*) FROM <table_name>
  2.  
This query will return the total number of rows in the table. If you want to find out the number of rows with certain data in them then you can specify that in WHERE clause.
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*) FROM <table_name> WHERE col1=value
  2.  
You can specify other columns in the WHERE clause by using the AND or OR operator.

I hope this helps.

Regards,
Pradeep
May 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4413
by: knoak | last post by:
Hi there, I have a small question: I have a table with lots of rows in it. Of course all have a different id, but each can be assigned to a certain category. Categories correspond with 1 - 10. So a row looks like this: 'unique id | 4' What i want is to do a count how much rows belong to a certain category.
1
2563
by: c.le_roq | last post by:
Hello, Using rollup I want to count the number of rows of a table called Table1 which is LEFT JOINED with a table called Table2. The problem is that we can have more than 1 rows in Table2 that matched 1 row in Table1. As a consequence the count of rows in table1 is bigger than the real number of rows contained in table1. For example:
0
4679
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get allways different count of rows. If anybody knows something about this kind of problem, I would appreciate any help. Thx.
2
3310
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
6
320
by: Kulwinder Sayal | last post by:
Hi In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched Thanks Kulwinder
6
6704
by: Tejpal Garhwal | last post by:
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ? Any idea ? Any Suggestions ? Thanks in advance Tej
1
6575
by: Fred Morrison | last post by:
Is it just me or is there something grossly wrong with the Windows Forms DataGrid control that won't tell me the row count inside it? I'm not talking about just visible rows (what the heck good is that, pray tell?). I want the TOTAL rows count in the DataGrid control. Oh sure, there could be a bound DataTable, DataView, or whatever that can be rextracted; but, that means my User Interface has to know something about how the data was...
68
6826
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
2
1117
by: Andy B | last post by:
I have a detailsView (replaced the formview with it) thinking it would help me fix my control access in a formview problem. Well, I don't think .net knows how to count. Here is what I have: I am trying to display the value of a certain cell in a label control. Say, NewsId for my example. In this example, NewsId should be 14. I took this line and used it to find out how many rows there were: DateConfirmLabel.Text =...
2
9102
by: John | last post by:
Hi I am using the below statement; Me.MyTableAdapter.Fill(Me.MyDataSet.tblMyTable) How can I now check the record count of the data table and specifically if the record count returned by fill is not 0? Thanks
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.