Hi rakibxl,
Please refer below Query.
SQL
DECLARE @TESTDEMO AS TABLE(Name VARCHAR(20), Code VARCHAR(20))
INSERT INTO @TESTDEMO VALUES('rakib','12')
INSERT INTO @TESTDEMO VALUES('Jack Ryan','34')
INSERT INTO @TESTDEMO VALUES('akabar',NULL)
INSERT INTO @TESTDEMO VALUES('suleiman','')
SELECT CASE WHEN NOT ISNULL(Code,'') = '' THEN Name + '(' + Code + ')'
ELSE Name END NameCode
FROM @TESTDEMO
Output
NameCode |
rakib(12) |
Jack Ryan(34) |
akabar |
suleiman |