How to check string NULL or empty in sql?

Check string is null or empty in sql server

We use ISNULL() for checking string null or empty

Select *
From Table
Where IsNull(columnname, '') = '' //if coulumn name null column value will be empty string

Select *
From Table
Where (columnname is null or col = '')

How to split string in sql through sql function?

You can create a function for split the string.

you have to declare 2 parameters, first string that you want to split and second delimiter.

Here the function below :

CREATE FUNCTION [dbo].[fnSplitString] 
    @string NVARCHAR(MAX), 
    @delimiter CHAR(1) 
RETURNS @output TABLE(splitdata NVARCHAR(MAX) 
    DECLARE @start INT, @end INT 
    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) 
    WHILE @start < LEN(@string) + 1 BEGIN 
        IF @end = 0  
            SET @end = LEN(@string) + 1
        INSERT INTO @output (splitdata)  
        VALUES(SUBSTRING(@string, @start, @end - @start)) 
        SET @start = @end + 1 
        SET @end = CHARINDEX(@delimiter, @string, @start)