Skip to content

Instantly share code, notes, and snippets.

@kevindb
Created July 6, 2016 18:52
Show Gist options
  • Save kevindb/02dde260366988dc95948643eb748162 to your computer and use it in GitHub Desktop.
Save kevindb/02dde260366988dc95948643eb748162 to your computer and use it in GitHub Desktop.
SQL Server function to return NULL for blank columns
CREATE FUNCTION [dbo].[f_nullForBlank]
(
@value VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
RETURN NULLIF(LTRIM(RTRIM(@value)), '')
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment