Query returns correct results, stored proc does not. Need a second set of eyes
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开发者_Python百科
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 varchar
stored procedure parameters.
e.g. use @cn varchar(30)
not @cn varchar
Currently everything you are passing in is getting truncated to 1 character so you are effectively doing the following search.
select
*
from
meet_cert_credit
where
Conf_number = '1'
and type_of_professional = 'C'
Hence no results.
精彩评论