Sunday, February 12, 2012

Are there wild cards for the =

I have a stored procedure where I'd like to be able to say

...
...
...
where FldName='*' if the fieldvalue was passed as null or
where fldName='whatever' if the fieldvalue was passed as non-null.

is this possible? Is there a workaround?Originally posted by DerFarm
I have a stored procedure where I'd like to be able to say

...
...
...
where FldName='*' if the fieldvalue was passed as null or
where fldName='whatever' if the fieldvalue was passed as non-null.

is this possible? Is there a workaround?

try this

... where ( FldName is Null ) or ( FldName = 'whatever' )|||Thanks, but where (fldname is null) will only match if the fldname is null ... not if John is in there.

I think I found the answer in a left join. I can left join the table to itself on the field in question and return only if the proper username is there.

Thanks

No comments:

Post a Comment