Hello,
Here is the solution to remove the rows from table when row count is reached to 12. this demo sample where we are maintaining users password in history (most recent 12 passwords) table for each users.
CREATE TRIGGER [dbo].[trgChangePassword] ON [dbo].[UserPassword]
FOR INSERT
AS
DECLARE @userid INT
DECLARE @totalrec INT
SELECT @userid = UserId FROM inserted
SELECT @totalrec=COUNT(*) FROM UserPassword where UserId=@userid;
IF @totalrec >= 12
BEGIN
DELETE FROM UserPassword WHERE Id IN (SELECT TOP 1 Id FROM UserPassword WHERE UserId=@userid ORDER BY id ASC)
End