Hello. The code below is part of a larger stored procedure to generate record IDs. This portion of the code is giving the following error message:
Server: Msg 170, Level 15, State 1, Line 11
Code:
DECLARE @id_int int
DECLARE @id_text varchar(13)
DECLARE @id_temp varchar(13)
DECLARE @CurrentYr int
SET @CurrentYr = convert(int, year(getdate()))
SELECT @id_temp = vchRoutingID,
case
when @CurrentYr = intCurrentYr then
@id_int = CONVERT(INT,SUBSTRING(vchRoutingID,8,DATALENGTH(vchRoutingID)-5))
when @CurrentYr > intCurrentYr then @id_int = 0 end
FROM tblRoutingID WITH (TABLOCKX,HOLDLOCK)
Individually, the lines work. So what might the problem be? Any help will be greatly appreciated. Thanks.