## how to count number of rows in a table column

 Author Message ALIF-662928 Right there with Babe Group: General Forum Members Points: 765 Visits: 743 Hi all, can any one send me the query to find the number of rows for a particular column,thanks RyanRandall SSCommitted Group: General Forum Members Points: 1761 Visits: 4652 Nicole (4/30/2008)Hi all, can any one send me the query to find the number of rows for a particular column,thanksYou have a terminology problem here, so it's hard to understand the question.Rows aren't parts of table columns; rows are parts of tables.Perhaps you mean one of these?`select count(Column) from Tableselect count(distinct Column) from Table`Post some example data and the result you'd want for that example. Ryan RandallSolutions are easy. Understanding the problem, now, that's the hard part. ALIF-662928 Right there with Babe Group: General Forum Members Points: 765 Visits: 743 Thanks, I guess you are right, I thought of somthing else. I have a table and my manager wants to update that column, so he asked me to tell how many rows will be affected in that column of a table when we are updating it. He want me to say the number of rows for that column, and you are right rows count for a table is same for the column. Grant Fritchey SSCoach Group: General Forum Members Points: 17635 Visits: 32268 You can get that specific count for your manager one of two ways. Safely:`SELECT COUNT(*)FROM MyTableWHERE MyColumn = 'OldValue'`Or not so safe:`BEGIN TRANUPDATE MyTableSET MyColumn = 'NewValue'WHERE MyColumn = 'OldValue'ROLLBACK TRAN`The first query will return the count. The second query will return the number of rows affected, but it won't do anything. However, you are mucking with the data, just rolling it back, so you will put a load on the system. It's not as safe. ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server Query Performance Tuning and SQL Server Execution PlansProduct Evangelist for Red Gate Software ALIF-662928 Right there with Babe Group: General Forum Members Points: 765 Visits: 743 Thanks Grant Fritchey,It helped me a lot. I have a problem in creating a view for my production db, i cannot post it here, if you can help me pls give me your email id, Its really critical for me to safe my job.Thanks again.