1) DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
2) Start by trying to find out what the problem is: remember that we have no idea what the SELECT statement is supposed to do, or any access to your DB to find out what it might be doing.
But there are some oddities there:
SET @MWHERE=@MWHERE
Does nothing.
So this code is completely redundant:
IF @CDCOMPT ='ALL'
BEGIN
SET @MWHERE=@MWHERE
END
And this code could probably use a space:
SET @MWHERE=@MWHERE+'AND A.COMP_TYPE=@CDCOMPT'
Try:
SET @MWHERE=@MWHERE+' AND A.COMP_TYPE=@CDCOMPT'
And "&" is an SQL Bitwise operator and will give you an error when applied to strings:
ON A.LNAME+''+A.FNAME+''+A.EMPNO= B.LNAME+''+B.FNAME+''+B.EMPNO
&@MWHERE
Probably you are trying to build a command, which implies you need "+" instead, but then you would have to build the whole command into a string and use EXEC to run it.