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 mean is null?
  • if looking @ blank values (empty strings) want consider null values?

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -