In SQL Server, I have a database mydb, and a table dbo.mytable in it.
I want to see if three columns (Contract_Number, Payment_Number, Task_Number) of the table can form a candidate key, by https://stackoverflow.com/a/34468508/156458
SELECT count (DISTINCT [Contract_Number], [Payment_Number], [Task_Number])
FROM [mydb].[dbo].[mytable]
but the execution gives an error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ','.
I was wondering what is going wrong?
Without count, it works fine. How should count and distinct be used together?
I also tried:
SELECT count(*)
FROM (SELECT DISTINCT [Contract_Number], [Payment_Number], [Task_Number]
FROM [PAD_Dev].[dbo].[Line_Level_Custom])
but the execution gives an error:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ')'.
Thanks.