Ramco Ramco

Ramco Ramco

  • 469
  • 2.8k
  • 392.2k

Incorrect Syntax near 0

Jul 10 2022 2:46 AM

BookId & StudentId has int DataType. Parameters value '0','20,21,22'

ALTER PROC [dbo].[USP_SessionBookPlanningSearch] --'0','20,21,22'
(
@BookID VARCHAR(500),
@StudentID VARCHAR(500)
)
AS
BEGIN

with ROWCTE as
(
SELECT * from View_Session
Where (('''+@@BookId+'''=''0'' OR BookID IN('+ cast(@@BookId as varchar(Max))+'))
and (('''+@@@StudentID+'''=''0'' OR StudentID IN('+ cast(@@@StudentID as varchar(Max))+'))

)

SELECT * FROM ROWCTE

end


Answers (1)