I have created a stored procedure which takes a parameter of type varchar(5)
. My stored procedure was working fine, and returning the correct result, until the time I passed it a string of 6 or more characters.
What happened is that it ignored 6th onward character, and returned result only based on first 5 characters, which was a wrong result. I expect it to throw an error when I am passing a longer string.
Is this a bug or there is way to change this behavior of SQL Server?
create procedure usp_testproc
@param1 varchar(5)
as
begin
if @param1 = '12345'
begin
select 'you got this right'
end
else
begin
select 'String Mismatch'
end
end
No matter whether we call
exec usp_testproc '12345'
or
exec usp_testproc '123456'
we get the same result