July 10, 2013 at 1:54 am
Is there a difference in these two queries??
1.
if not Exists (select TimeOffEntryId from TimeOffEntry where FinancialYearId = 1 and AWOLUserId = 'ST01574' and LeaveTypeId = 16)
(select 1)
else
(select -1)
2.
exec sp_executesql N'
if not Exists (select TimeOffEntryId from TimeOffEntry where FinancialYearId = @financialYearId and AWOLUserId = @awolUserId and LeaveTypeId = leaveTypeId)
(select 1)
else
(select -1)
',N'@awolUserId varchar(7),@financialYearId int,@leaveTypeId int',@awolUserId='ST01574',@financialYearId=1,@leaveTypeId=16
The second query is taken from sql profiler. Both run on same table but the first one gives me a correct result that is 1, however the second gives me -1. I am so confused..I dont know may be it is a silly error that I cant figure out. :S
July 10, 2013 at 2:15 am
it was a silly typo :s...
@leavetypeid
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply