I’m using the following procedure in one of my projects.
create procedure [dbo].[SMSStudentSelect2]
@Sorp char(20)
as
begin
select @Sorp PhoneNo from Students
where DATALENGTH(@Sorp) = 11 and ClassId = 1
and GRNo not in(select GRNo from Discharge)
end
my problem is: when I put SPhoneNo in the parameter @Sorp I get no result while when i directly use SPhoneNo i.e I use the query like
select SPhoneNo from Students where DATALENGTH(SPhoneNo) = .........
in my procedure, I Get the disired result
Can anyone please solve my problem????
EDIT based on comments to determine what the OP wants:
try something like this:
pass in a “S” or a “P” to get the column you want.