by Jim
Sep 13, 2010 11:21 AM
An IsNullOrEmpty function for SQL. I hate that the database I’m working with makes it necessary to write such a thing…
CREATE FUNCTION [dbo].[fcn_IsNullOrEmpty]
(
@string VARCHAR(4000)
)
RETURNS BIT AS BEGIN DECLARE @isnullorempty BIT SET @isnullorempty = 0
IF @string IS NULL SET @isnullorempty = 1
ELSE IF RTRIM(LTRIM(@string)) = '' SET @isnullorempty = 1
RETURN @isnullorempty
END