I have one written one query as per below. Its not giving result when i did sub- string.
Declare @Result varchar(max) set @Result=(select top 1 value from empkeyValue) select * from department d where (SUBSTRING('department4', 1, 11)+Convert(varchar(10), 4)) = @Result
Here when i wrote this condition
(SUBSTRING('department4', 1, 11)+Convert(varchar(10), 4)) = @Result , there is no output. What is wrong in this query. please help me.
SUBSTRING is having some issue. i m not able to find what is the problem here. after substring and concatenation with 4, it will give department4 which is actual column in table.
If i write like this as per below query, it will give result. But I do not want to hard code
department4. It should be dynamic as per above query.
select * from department d where department4= @Result