views:

28

answers:

1

If I have that constraint on a table,

 (field1 is null and field2 is not null and dbo.expensivefunction(field2) = field3)

If my field2 is null, is the function will be called anyway?

Is "and" equal the meaning of (andalso, &&) in .Net in a constraint on sql server 2005?

+1  A: 

SQL Server does short circuit operations, but the order of the operations depends on the optimizer so the answer is maybe. See this blog entry. In practice, I've used statements such as yours without problems -- probably because the optimizer puts the simpler checks first, though there isn't a guarantee.

tvanfosson
thanks for giving me the expression "short circuit evaluation" I didn't know how to call that
Fredou