Lately (because of my line of work) I am using SQL Server more than I am using Visual Studio. I miss some of the functions provided in C# however.
One of them is String.IsNullOrEmpty and SQL Server does not natively have it.
Dead simple, but a comfort in long CASE statements:
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE FUNCTION [dbo].[IsNullOrEmpty] (@string_val varchar(8000))
WITH EXECUTE AS CALLER
IF @string_val IS NULL OR @string_val = '' RETURN 1
Usage is simple and according to expectations:
WHEN dbo.IsNullOrEmpty('') = 1 THEN 'NullOrEmpty'
ELSE 'Not NullOrEmpty'
Unfortunately I do not know of a way to avoid the "= 1" as I do not think boolean/bit values are handled the same in SQL.