Hello,
You can do this by either creating a trigger during insert, or modify the default value for your identity column. Take this as an example.
CREATE FUNCTION CompanyBasedId (@id int, @company varchar(6))
RETURNS varchar(10)
AS
BEGIN
RETURN @company + Right('0000' + Convert(varchar(10), @id), 4)
END
ALTER TABLE YOURTABLENAME ADD CustomId as dbo.CompanyBasedId(id, company)
The script above should have a table structure like this one.
YOURTABLENAME
id (autoincrement int column)
company (company code varchar(6))
customId (your customized autoincrement column thats based on id and company column)
Regards.