I have the following query:I want to use distinct which is in table A.CNIDi want to use distinct A.CNID,A.* in select query I am getting following error, Can you please help:Server: Msg 8163, Level 16, State 3, Line 1The text, ntext, or image data type cannot be selected as DISTINCT.SELECT Distinct A.CNID,A.*,C.ProgNO AS ProgNO, D.ProjNO AS ProjNO, E.ContractNO AS ContractNO, B.AccessMode FROM TAB_ccsNetCN A INNER JOIN TAB_ccsNetUserAccess B ON A.ProgID = B.ProgID AND A.ProjID = B.ProjID AND A.ContractID = B.ContractID INNER JOIN TAB_ccsNetPrograms C ON C.ProgID = A.ProgID INNER JOIN TAB_ccsNetProjects D ON D.ProjID = A.ProjID INNER JOIN TAB_ccsNetContracts E ON E.ContractID = A.ContractID WHERE B.UserName = 'JOHN' AND A.CNID = 508 and a.deleted=0 AND B.Deleted = 0 AND B.ccsNetModule = 'CN'
If i don't use the distinct it is getting 5 records for same id 508. i want to get only one record with the above query, but it is throwing an error for the distinct.Thank you very much for the help.