# Database Discussions > Sybase >  Sybase syntax Error please Help URGENT

## azfariqbal

i have table table1 in which i am entering this id as varchar
Genralize view
KUJO.YEAR.MONTH.AUTOINCREAMENT NOS FROM LAST ONE
for example KUJO.05.08.01

WHERE 05 = YR
     08 = MONTH
     01 = START WHEN MONTH CHAGES

*******sTORED pROCEDURE *******************

Create Procedure proc_kujoID

As
declare @KUJO_ID varchar(50),@month1 varchar(30),@year1 varchar(30),@sequence1 varchar(30),@return varchar(50)
Select @month1 = Convert(varchar(30),datepart(month,getdate()))

Select @year1 = Convert(varchar(30),datepart(year,getdate()))
If Len(@month1) = 1
Select  @month1 = "0" + @month1
If Len(@year1)>2
Select  @year1 = Substring(@year1,3,2)
Select @sequence1 = Convert(varchar(30),Max(Convert(int,str_replace(KU  JO_ID,"KUJO." + Convert(varchar(30),@year1) + "." + Convert(varchar(30),@month1)+".",""))))
From KujoID

Select  @sequence1 = Convert(varchar(30),Convert(int,@sequence1) + 1)
If @sequence1 Is Null
Select  @sequence1 = "01"
Else If len(@sequence1) = 1


Select
@sequence1 = "0" + @sequence1
Select  @return = "KUJO." + Convert(varchar(30),@year1) + "." + Convert(varchar 30),@month1)+"." + @sequence1

Insert Into KujoID(KUJO_ID,DateTime)
Values(@return,getDate())

Select @return as KUJOID
GO


*******************************************

EVERY THING FINE IT ADDING EVERYTHING AS I EXPECTED
KUJO.05.08.01
KUJO.05.08.02
KUJO.05.08.03
KUJO.05.08.04

I THINK BECAUSE TABLE WAS EMPTY AND IT RETURN NULL
BUT NOW MONTH CHANGE FROM 08 TO 09
THEN IT IS GIVING ME THE SYNTAX BELOW IS THE ERROR

************ERROR***************

Server Message:  Number  249, Severity  16
Syntax error during explicit conversion of VARCHAR value 'KUJO.05.08.01' to a INT field.
(1 row affected)
(return status = -6)

**********************************

PLEASE HELP ME OUT IT IS VERY URGENT

THANKS IN ADVANCE

----------

