First there is no need for a variable. Write the query as: Select l.username AS UName, isnull(l.useremail,'NA') AS UEmail from tbl_login l join tbl_main m ON m.column_name = l.designation where tbl_login.designation = @ID I here used m.column_name, as it is not clear to me what is the name of the column tbl_main. I also dropped the isnull around username, because of the login does ...



