The kishorekke's answer is almost perfect, but need some explonations.
The below line is the reason of error:
set @lquery='select SalName,Amount from tbl_SalaryAssign where CompanyID=@cid'
The input parameter:
@cid
as
VARCHAR
for stored procedure is declared but it's never used. Why? read the kishorekke's answer.
I see 2 additional, potential reasons of problems.
1)
VARCHAR
without size stores default only 1 sign.
Use:
@cid VARCHAR(30)
2)
The
CompanyID
field stores probably integer values.
What i'm trying to explain you, is:
'1'
is not equal to
1
If i'm right, the
@cid
must be an integer variable.