Loading...

COUNT of DISTINCT Rows in SQL Server

View: 1586    Dowload: 0   Comment: 0   Post by: naruto   Category: SQL Server   Fields: Other

SELECT COUNT(DISTINCT *) FROM Employees

 
The error message generated is:
 

Incorrect syntax near '*'

 
Instead, use the below query:

SELECT COUNT(*) FROM (SELECT DISTINCT * FROM Employees) Emp

 

COUNT of DISTINCT Rows in SQL Server

SQL Server does not support COUNT(DISTINCT *). For example, the below query fails.

Posted on 06-05-2014 

Comment:

To comment you must be logged in members.

Files with category

  • Data Encryption in SQL Server using T-SQL Functions (ENCRYPTBYPASSPHRASE, DECRYPTBYPASSPHRASE & HASHBYTES)

    Data Encryption in SQL Server using T-SQL Functions (ENCRYPTBYPASSPHRASE, DECRYPTBYPASSPHRASE & HASHBYTES)

    View: 469    Download: 0   Comment: 0

    Category: SQL Server     Fields: Other

    Decade ago data was just an entity which helped business to operate smoothly. By then data was considered as some sort of business related information just stored in a database, which can be retrieved based on the demand/requirement as per the...

  • Building a Multi-Cloud Strategy

    Building a Multi-Cloud Strategy

    View: 272    Download: 0   Comment: 0

    Category: SQL Server     Fields: Other

    Today, few companies are in a position to leverage a single cloud for all their needs. Even as service providers add multiple services like email and collaboration to try to keep people in the ecosystem, companies need a multi-cloud strategy.

  • Insufficient access rights error when doing backup in SQL Server

    Insufficient access rights error when doing backup in SQL Server

    View: 663    Download: 0   Comment: 0

    Category: SQL Server     Fields: none

    All of sudden SQL Server Management studio gives me the following error message when I'm trying to browse for the backup file location.

  • Migrate MySQL to Microsoft SQL Server

    Migrate MySQL to Microsoft SQL Server

    View: 2784    Download: 0   Comment: 0

    Category: SQL Server     Fields: none

    This article describes a few simple steps in order to migrate MySQL into Microsoft SQL Server 2005. The technique is very easy, but useful if you plan to move your data from MySQL and upgrade it finally to a Microsoft SQL Server environment.

  • COUNT of DISTINCT Rows in SQL Server

    COUNT of DISTINCT Rows in SQL Server

    View: 1586    Download: 0   Comment: 0

    Category: SQL Server     Fields: Other

    SQL Server does not support COUNT(DISTINCT *). For example, the below query fails.

  • Finding SQL Servers on the Network

    Finding SQL Servers on the Network

    View: 926    Download: 0   Comment: 0

    Category: SQL Server     Fields: Other

    I am a TSQL fanatic. The programs I code are highly dependent upon MS SQL stored procedures. I pay for this love of TSQL when a major overhaul of the system is necessary. Sometimes my code needs to be updated heavily in two places; client and...

  • SQL Server and Database Enumerator

    SQL Server and Database Enumerator

    View: 940    Download: 0   Comment: 0

    Category: SQL Server     Fields: Other

    This sample helps you to enumerate the list of SQL Servers and the databases and languages that a particular SQL server has. The class CSQLInfoEnumerator encapsulates this functionality into it.

  • Dynamic Management Views [DMV] – A SQL Server 2005 Feature

    Dynamic Management Views [DMV] – A SQL Server 2005 Feature

    View: 909    Download: 0   Comment: 0

    Category: SQL Server     Fields: Other

    The DMVs; newly introduced in SQL Server 2005 gives the database administrator information about the current state of the SQL Server machine. These values will help the administrator to diagnose problems and tune the server for optimal performance....

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd