I don't know the source for the values you need to auto-increment, but you should be able to solve the problem using T-SQL code that looks something like this:
DECLARE @StartAt INT = 0
SELECT 'XS' + REPLACE(STR(1 + @StartAt, 6), SPACE(1), '0')
For the sake of example, suppose your starting value is 745; then the code looks like this:
DECLARE @StartAt INT = 745
SELECT 'XS' + REPLACE(STR(1 + @StartAt, 6), SPACE(1), '0')
If you are incrementing an integer value in a database table, then the solution might look like this:
CREATE TABLE #TempCounter (ID INT)
INSERT INTO #TempCounter (ID) VALUES (1)
INSERT INTO #TempCounter (ID) VALUES (2)
INSERT INTO #TempCounter (ID) VALUES (3)
INSERT INTO #TempCounter (ID) VALUES (4)
DECLARE @StartAt INT = (SELECT MAX(ID) FROM #TempCounter)
SELECT 'XS' + REPLACE(STR(1 + @StartAt, 6), SPACE(1), '0')
DROP TABLE #TempCounter
If you are incrementing a string value in a database table, then the solution might look like this:
CREATE TABLE #TempCounter (ID NVARCHAR(8))
INSERT INTO #TempCounter (ID) VALUES ('XS000100')
INSERT INTO #TempCounter (ID) VALUES ('XS000101')
INSERT INTO #TempCounter (ID) VALUES ('XS000102')
INSERT INTO #TempCounter (ID) VALUES ('XS000103')
DECLARE @StartAt INT = (SELECT CAST(RIGHT(MAX(ID),6) AS INT) FROM #TempCounter)
SELECT 'XS' + REPLACE(STR(1 + @StartAt, 6), SPACE(1), '0')
DROP TABLE #TempCounter
Let me know if this answers your question. My examples assume SQL Server, but perhaps you are using a different platform?