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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query

Author  Topic 

Gokila
Starting Member

2 Posts

Posted - 2011-05-27 : 02:30:12

This is my code
it shows some error like

Msg 137, Level 15, State 2, Procedure Sp_ReportStudContacts, Line 28
Must declare the scalar variable "@Hostler".



set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[Sp_ReportStudContacts]
(
@ClassID bigint,
@SectionID bigint,
@StudType varchar(50)
)


As

SELECT
CM.ClassName,
SM.SectionName,
SD.StudentCode,
SD.StudentName,
SD.PresentAddress,
SD.PermenantAddress,
SD.PhoneNo,
SD.Hostler,
SD.ClassID,
SD.SectionID,
SD.StudentID

FROM StudentDetails SD INNER JOIN
ClassMaster CM ON SD.ClassID=CM.ClassID INNER JOIN
SectionMaster SM ON SD.SectionID=SM.SectionID

WHERE (SD.ClassID=@ClassID) AND (SD.SectionID=@SectionID) AND (CONVERT(VARCHAR(50),SD.Hostler)=CONVERT(VARCHAR(50),@Hostler))

--EXEC Sp_ReportStudContacts @ClassID='1',@SectionID='1'


Please Help me


R.Gokila

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-27 : 02:58:53
Self explanatory.
@Hostler is not defined
I'm guessing it needs to be a parameter and passed to the SP.
You're not passing @Stud in the call either or using it - maybe that should be @Hostler.

I suspect there is no need for the convert statements there - and the brackets ae just confusing things.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -