Saturday, February 25, 2012

Can I use a UDF in an IF statement?

Is it possible to use a user defined function in an IF statement? The UDF returns a scalar value. Like:
IF dbo.DoSomething (@.x)

The only way I can see to call a UDF is with
SELECT @.y = dbo.DoSomething (@.x)


Thank you!

YES but you have to compare its result with something or your function should return bit or integer value IF dbo.DoSomething (@.x)=1

No comments:

Post a Comment