March 26, 2010 at 1:17 pm
Which option has better performance? or both are the same?
Declare @id int
Declare @ClientId int
set @clientID = 1
Select @id = id from [Table] where id = @ClientID
If @Id is null
Begin
-- run a process
END
OR
Declare @id int
Declare @ClientId int
set @clientID = 1
If not exists (Select 1 from [Table] where id = @ClientID)
Begin
-- run a process
END
I have seen the same time result, the second options has less code.
What is your opinion?
March 26, 2010 at 1:27 pm
MTY-1082557 (3/26/2010)
Which option has better performance? or both are the same?
Declare @id int
Declare @ClientId int
set @clientID = 1
Select @id = id from [Table] where id = @ClientID
If @Id is null
Begin
-- run a process
END
OR
Declare @id int
Declare @ClientId int
set @clientID = 1
If not exists (Select 1 from [Table] where id = @ClientID)
Begin
-- run a process
END
Personal preference, the second option is the one I'd probably use.
I have seen the same time result, the second options has less code.
What is your opinion?
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply