Click here to Skip to main content
15,905,971 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI I have created the below stored procedure this is working fine but fetching duplicate records with same date.
SQL
SELECT  
    RB.Billing_Account_ID__c AS AccountNumber,
    AR.Phone__c AS PhoneNumber,
    T.CreatedDate AS CreatedDate,  
    U.Name AS UserName,
    T.[Description] AS [Description],  
FROM Account AS AR    
    LEFT JOIN BCAccount AS  RB ON AR.ID = RB.Residential_Account__c  
    LEFT JOIN MyTask  AS T ON AR.ID = T.WhatId   
    LEFT JOIN [User] AS  U ON T.OwnerId=U.Id  
WHERE  T.[Subject] = 'ABC Testing' 
    and BETWEEN @PastDateTime AND @CurrentDateTime


My result is displaying like below
2016-04-24 23:44:08.000
2016-04-24 23:44:08.000
2016-04-24 23:44:08.000

the above records are same and displaying as duplicate

i wnat to avoid duplicate.
Could you please help on this.

What I have tried:

I have tried to avoid duplicate by using the below things but it is not working in my select command
SQL
CONVERT(VARCHAR(10), YourDateColumn, 101),

i am getting "ntext data is not supporting distinct in sql server".
Posted
Updated 25-Apr-16 0:43am
v2
Comments
Tomas Takac 25-Apr-16 2:21am    
I'm confused. You are selecting 5 columns yet you claim your result is just a single date time column. What's the actual output of the select statement you have there?
Karthik_Mahalingam 25-Apr-16 3:26am    
why dont you use distinct keyword

1 solution

Solved, the problem is not datetime filed, another filed is type is ntext that i have converted into nvarchar with max
I got solution. Thank you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900