Ramco Ramco

Ramco Ramco

  • 436
  • 3.4k
  • 545.7k

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)