I've been having problems with the following query. It falls over on the first BEGIN but I can't se why.
Any sugguestions?
Set transaction isolation level read uncommitted
Declare @.Date DateTime
Declare @.Msg VarChar(255)
set @.Date = Getdate()-44
If (Select z.lastamendedby from dbo.intray as z
Where z.lastamendedby in
(select x.userid from dbo.useractivity as x left join dbo.users as y on x.userid = y.user_id
where x.lastactivityTime < @.Date))
--and y.ntSuspended = 0)
--and z.lastamended > @.Date
Begin
set @.Msg = "These users have done work since the 44 day period, don't suspend"
Print @.Msg
End
Else
Begin
Select z.lastamendedby from dbo.intray as z
Where lastamendedby in
(select x.userid from dbo.useractivity as x left join dbo.users as y on x.userid = y.user_id
where x.lastactivityTime < @.Date
and y.ntSuspended = 0)
Set @.Msg = "These users haven't done any work since the 44 day period, suspend"
Print @.Msg
End
Cheers,
Jim
Because you didn't finish your IF.
If you reduce it down, maybe you'll see:
IF (SELECT lastamendedby)
BEGIN
Just out of curiosity, what company do you work for? Cause I'm definately interested in finding one that only suspends you if you haven't done anything for 44 days ;-p
No comments:
Post a Comment