Conversion failed when converting the nvarchar value ... to data type int
You are trying to concatenate a string and an integer.
You need to cast @ID
as a string.
try:
SET @sql=@sql+' AND Emp_Id_Pk=' + CAST(@ID AS NVARCHAR(10))
Try Using
CONVERT(nvarchar(10),@ID)
This is similar to cast but is less expensive(in terms of time consumed)