first ensure that the value you are getting in @pid is int or varchar. If column data type is varchar then use CAST for it.
Hope, It will works for you 😛
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/