The table design is a bit odd. Ideally, ApplicationID should have been an identity column so that SQL server will auto-increment it for you. But, hey, we all deal with legacy systems where some portions are out of our control.
See below SQL fiddle for one way of doing this. Obviously, it will break down when you have more than 999 apps, so you'd have to deal with that:
SQL Fiddle
MS SQL Server 2017 Schema Setup:
CREATE TABLE Application (Id varchar(3), ApplicationName varchar(max))
CREATE TABLE AppCategory (Id varchar(2), CategoryName nvarchar(max))
CREATE TABLE AppPerCategory (CategoryId varchar(2), ApplicationId varchar(3), SeqIndex int)
INSERT Application VALUES ('091', 'foo')
INSERT AppCategory VALUES ('00', 'test category')
INSERT AppPerCategory VALUES ('00', '091', 1)
Query 1:
-- Assume below two are inputs for creating new application
DECLARE @newAppName varchar(max) = 'new application'
DECLARE @category varchar(max) = 'test category'
-- Below will set newAppId to 092. Not you have to adjust for when # apps > 999
DECLARE @newAppId varchar(3) = (SELECT REPLACE(STR(CAST(MAX(Id) AS int) + 1, 3), ' ', 0) FROM Application)
DECLARE @categoryId varchar(2) = (SELECT Id from AppCategory WHERE CategoryName = @category)
DECLARE @newCategorySeqIndex int = (SELECT MAX(SeqIndex) + 1 FROM AppPerCategory WHERE CategoryId = @categoryId)
INSERT Application (Id, ApplicationName)
VALUES (@newAppId, @newAppName)
INSERT AppPerCategory (CategoryId, ApplicationId, SeqIndex)
VALUES (@categoryId, @newAppId, @newCategorySeqIndex)