Mehram
asked on
MS SQL max id
Sir, I am using below statement and it is showing error following:
select MAI=max(acc_id)+1, x.Paraccountid from
(select acc_id, paraccountid, title from AC_CHARTOFACC where paraccountid ='1002001001')x
group by x.paraccountid
Error:
Server: Msg 248, Level 16, State 1, Line 1
The conversion of the varchar value '1002001001001' overflowed an int column. Maximum integer value exceeded.
Please help how to resolve this problem.
Rgds.
Mehram
select MAI=max(acc_id)+1, x.Paraccountid from
(select acc_id, paraccountid, title from AC_CHARTOFACC where paraccountid ='1002001001')x
group by x.paraccountid
Error:
Server: Msg 248, Level 16, State 1, Line 1
The conversion of the varchar value '1002001001001' overflowed an int column. Maximum integer value exceeded.
Please help how to resolve this problem.
Rgds.
Mehram
the fields acc_id and paraccountid need to be of data type bigint, and not int
sorry i meant:
Hi Mehram,
change the datatype from int to long in the table
:o)
Hi Mehram,
change the datatype from int to long in the table
:o)
ASKER
Sir the acc_id and paraccountid both are varchar (100)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this query....
If its a varchar field, you have to convert it to a numeric field
We can make use of CONVERT funtion or CAST function for this purpose...
Convert(data type,field name)
Cast (field name as data type)
select MAI=max(convert(numeric,ac c_id))+1, x.Paraccountid from
(select acc_id, paraccountid, title from AC_CHARTOFACC where paraccountid ='1002001001') x
group by x.paraccountid
If its a varchar field, you have to convert it to a numeric field
We can make use of CONVERT funtion or CAST function for this purpose...
Convert(data type,field name)
Cast (field name as data type)
select MAI=max(convert(numeric,ac
(select acc_id, paraccountid, title from AC_CHARTOFACC where paraccountid ='1002001001') x
group by x.paraccountid
change the datatype from int to long in the table