Sunday 18 July 2010

count columns table in sql server

1) you can get the number of
columns in a table using SQL?


SELECT count(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Your Table Name'


2) Count Duplicate Records – Rows

SELECT Your_Column_Name, COUNT(*) Total_Count FROM Your_Table_name
GROUP BY Your_Column_Name
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC

3) The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column:

SELECT COUNT(column_name) FROM table_name

4)The COUNT(*) function returns the number of records in a table:

SELECT COUNT(*) FROM table_name


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger