Saturday , November 23 2024

APPROX_COUNT_DISTINCT Function in SQL Server(TSQL)

 

This function returns an estimated number of non-null unique values in a data set. It came with SQL Server 2019. Let’s create a table with the Identitiy column and add a few records to this table.

You can use the APPROX_COUNT_DISTINCT Function as follows.

Since this function comes with SQL Server 2019, you will get the error as follows when you want to run this function in a previous version.

Msg 195, Level 15, State 10, Line 14

‘APPROX_COUNT_DISTINCT’ is not a recognized built-in function name.

You may also receive a “is not a recognized built-in function name” error if you did not specify the path of the function correctly.

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *