SQL Server xQuery return NULL instead of empty

后端 未结 1 876
栀梦
栀梦 2020-12-21 06:19

So in this example I\'m trying to return a NULL instead of an empty nvarchar for element2 and element3. I can\'t seem to find an answer to this anywhere, or if it\'s even po

相关标签:
1条回答
  • 2020-12-21 06:56

    I'm not sure what language you are writing in from your question, but SQL Server has a NullIf(val, CheckValue) function. If you can include that in the sql you pass to the server that should do the trick:

       Select NullIf(element2, '') 
    

    will return a null if element2 is equal to an empty string ('')

    0 讨论(0)
提交回复
热议问题