>>>Hi All,
>>>
>>>how can i use this line Iif(Empty(thisform.txtID.Value),'.t.','CrsTable.ID=thisform.txtID.value') in T-Sql where clause?
>>>
>>>Thanks
>>
>>Solved myself :)
>>
>>WHERE vw_CrsStokhb.fiskodu = CASE WHEN @fiskodu is not null then @fiskodu ELSE vw_CrsStokhb.fiskodu END
>
>Please read this blog post
http://blogs.lessthandot.com/index.php/datamgmt/datadesign/do-you-use-column-param-or-param-is-null/ and blogs referenced in the comments to it.
sql engine does not optimize the variables,
because it generates the plan without assessing the value of the variable.
optimizes literals, written explicitly in the query.
This is a disaster in the functions!
I understand the SQL team's difficulties,
max NULL in a variable is a special case,
and can generate a plan that takes into account,
improving the performance of orders of magnitude