Go to SQL as Admin, AXDB database:
pass your table(Custable) and run below query:
DECLARE @MaxRecID BIGINT
DECLARE @NextVal BIGINT
SELECT @MaxRecID = MAX(RECID)
FROM custtable
SELECT @NextVal = NEXTVAL
FROM SYSTEMSEQUENCES
INNER JOIN SQLDICTIONARY
ON SQLDICTIONARY.FIELDID = 0
AND SQLDICTIONARY.name = 'custtable'
AND SQLDICTIONARY.TABLEID = SYSTEMSEQUENCES.TABID
IF (@NextVal > @MaxRecID)
BEGIN
PRINT 'custtable did not need to be updated.'
END
ELSE
BEGIN
PRINT 'Updated custtable from ' + CONVERT(VARCHAR(MAX), @NextVal) + '' to '' + CONVERT(VARCHAR(MAX), @MaxRecID + 1)
UPDATE SYSTEMSEQUENCES
SET NEXTVAL = @MaxRecID + 1
FROM SYSTEMSEQUENCES
INNER JOIN SQLDICTIONARY
ON SQLDICTIONARY.FIELDID = 0
AND SQLDICTIONARY.name = 'custtable'
AND SQLDICTIONARY.TABLEID = SYSTEMSEQUENCES.TABID
END
No comments:
Post a Comment