Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SP.. must declare scalar variable

Author  Topic 

Pasi
Posting Yak Master

166 Posts

Posted - 2015-04-07 : 16:43:59
HI. I am creating a SP below and it keep saying must declare scalar variable @comments, what am I doing wrong? I have already declared @comments varchar (255)


error---> (Msg 137, Level 15, State 2, Procedure CheckPatientComments, Line 26
Must declare the scalar variable "@commnets".
)

thanks.

quote:

CREATE PROCEDURE [dbo].[CheckPatientComments] (@enc_id varchar(36) OUTPUT, @data_ind CHAR(1) OUTPUT)

AS
BEGIN
DECLARE
@comments varchar(255)

select @comments= a.comments

from allergy_table_ a
inner join patient_encounter pe on pe.person_id= a.person_id
INNER JOIN person p ON p.person_id = a.person_id
where pe.enc_id= @enc_id

IF (@commnets <>'' or @comments is not null)
--select @comments= 1
select @data_ind= 'Y'
select @comments= @comments


SET NOCOUNT Off;

end


GO





Pasi
Posting Yak Master

166 Posts

Posted - 2015-04-07 : 16:50:36
I think Ijust found out whats wrong. I have a type in word "comments" never mind..
Go to Top of Page

kostya1122
Starting Member

15 Posts

Posted - 2015-04-08 : 13:36:41


CREATE PROCEDURE [dbo].[CheckPatientComments] (@enc_id varchar(36) OUTPUT, @data_ind CHAR(1) OUTPUT)

AS
BEGIN
DECLARE
@comments varchar(255)

select @comments= a.comments

from allergy_table_ a
inner join patient_encounter pe on pe.person_id= a.person_id
INNER JOIN person p ON p.person_id = a.person_id
where pe.enc_id= @enc_id

IF (@commnets <>'' or @comments is not null) ----------------------------- typo you putt @commnets
--select @comments= 1
select @data_ind= 'Y'
select @comments= @comments


SET NOCOUNT Off;

end


GO
Go to Top of Page
   

- Advertisement -