Reputation: 5504
A comment in this question:
Do not rely on short-circuiting ... Those clauses could be evaluated in any order SQL Server sees fit.
As it relates to this answer:
SELECT * FROM TABLE WHERE (@vari is null or col = @vari)
I ask this because I haven't found anything online that explicitly states this.
Upvotes: 1
Views: 260
Reputation: 107716
Read here
Sample setup
create table albert(a int NOT NULL,
b varchar(23) NOT NULL)
create table stina (a int NOT NULL)
go
insert albert (a, b)
values (1, '99'),
(2, 'Gurka'),
(3, '89')
insert stina (a) values(1), (3), (9), (12)
go
SELECT a.a, a.b + 100
FROM albert a
JOIN stina s ON s.a = a.a
Upvotes: 1