sql server - IF statement in MS SQL when function return empty string -
i need check when function in ms sql return empty string ('') in insert table , handle condition. don't know how. use syntax:
insert [db].[dbo].[tablesnames] (name) values (case when [dbo].function(@id, @externalname, @level) '' @name else [dbo].function(@id, @externalname, @level))
how correct syntax in case? thx advance.
i more inclined write as:
insert [db].[dbo].[tablesnames](name) select (case when x = '' @name else x end) (select [dbo].function(@id, @externalname, @level) val) x;
functions incur overhead when called. formulation gives sql server opportunity evaluate function once.
a couple more things:
- i don't recognize
is
. might meanis null
? - if looking @ blank values (empty strings) want consider
null
values?
Comments
Post a Comment