Does your EmployeeID
and PropertyID
parameters really need to be varchar(max)
, I find it hard to believe that an employee would have an ID with 8 000 characters. The same goes for the property ID. Change this to how many characters they are allowed to have (e.g., if an employee can only have an ID of 8 characters then use that, if it's 100 characters use that, and if it indeed is 8 000 characters, well then I suppose varchar(max) is fine)
I'd also advocate to use clearer aliases for your column. Instead of as PId
you should alias it as as PropertyID
.
This line is a bit unclear to me WHERE TblA.RegionID > 0
. Can a Region have an ID of 0 or less-than 0?
I also think that the LIKE
in this line TblA.PropertyID LIKE '%' + @PropertyID + '%'
is used for the wrong purpose. It seems like what you really are doing is comparing the PropertyID of TblA.PropertyID
to the parameter PropertyID@PropertyID
and in my opinion there should be no need of using wildcards here. Instead use the equals operator.