hi nedash,
Refer the below test query for tour reference.
DECLARE @Film AS TABLE(Id INT,Genre1 VARCHAR(10),Genre2 VARCHAR(10),Genre3 VARCHAR(10))
INSERT INTO @Film
SELECT 1,'Drame',' ','Action'
UNION ALL
SELECT 2,'','Family','Action'
SELECT DISTINCT Genre1 as Genre
FROM @Film
WHERE LTRIM(RTRIM(ISNULL(Genre1,''))) <> ''
UNION ALL
SELECT DISTINCT Genre2 as Genre
FROM @Film
WHERE LTRIM(RTRIM(ISNULL(Genre2,''))) <> ''
UNION ALL
SELECT DISTINCT Genre3 as Genre
FROM @Film
WHERE LTRIM(RTRIM(ISNULL(Genre3,''))) <> ''
OUTPUT
Genre |
Drame |
Family |
Action |