My Query:
select
*
from
meet_cert_credit
where
conf_number = '1132'
and type_of_professional = 'Certified Hazardous Materials Managers'
My stored procedure:
ALTER PROCEDURE [dbo].[sp_check_credit_info]
@cn varchar = NULL,
@top varchar = NULL
AS
BEGIN
SET NOCOUNT ON;
select
*
from
meet_cert_credit
where
Conf_number = @cn
and type_of_professional = @top
END
Calling my stored proc:
exec sp_check_credit_info '1132', 'Certified Hazardous Materials Managers'
When running the query, it returns results. When running the stored procedure, I get nothing.
Am I insane?
You need to give a length to your
varcharstored procedure parameters.e.g. use
@cn varchar(30)not@cn varcharCurrently everything you are passing in is getting truncated to 1 character so you are effectively doing the following search.
Hence no results.