May 31, 2010 at 3:58 am
You can check the new requirement with the same query. Execute the query with @vVarTime variable first with StartTime and then with End time (or use OR operator in the where clause)
and the result should be NULL i.e. no record should return. If the record comes, it means its been duplicated / repeated time.
May 31, 2010 at 4:26 am
urzsuresh (5/30/2010)
Its was nice. But one clariffication. here Starttime and endtime is nchar(10) type.
It is never a good idea to store date and time data in string format.
i need to get the result without using any functions.
The function I included was to show you how to wrap re-usable code in an efficient way.
The person asking you to remove the function seems confused about the difference between scalar, multi-statement, and in-line functions.
It is pretty trivial to copy the body of the function out to a separate statement, it just seems like a dumb idea to me.
I need another one more help. When user try to insert start time and endtime, we need to validate (i.e start time and endtime should not repeat again.)
One way to do this would be to use a trigger.
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
May 31, 2010 at 5:20 am
Can you please sample code
May 31, 2010 at 5:37 am
Hello Friend,
I have check the duplicate data like this.
if Exists (Select * ,@vVarTime
from @vShiftTable
where case when Convert(datetime,Convert(varchar(10),@vVarTime,108)) > '1900-01-01 00:00:00' and Convert(datetime,Convert(varchar(10),@vVarTime,108)) <= @vMultiDateTime
then
DateAdd(dd,1,Convert(datetime,Convert(varchar(10),@vVarTime,108)))
else
Convert(datetime,Convert(varchar(10),@vVarTime,108))
end
between
Convert(datetime,Convert(varchar(10),startTime,108))
and
case when startTime > EndTime then
DateAdd(dd,1,Convert(datetime,Convert(varchar(10),EndTime,108)))
else
Convert(datetime,Convert(varchar(10),EndTime,108))
end
)
Print 'Duplicate'
Else
Print 'No Duplicate'
Is there any other way to find duplicate
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply