Not sure if this is what you are looking for, but if you insert records and then retrieve the last generated identification value, you can use SELECT SCOPE_IDENTITY () after your insert ...
INSERT INTO MyTable (col1, col2)
VALUES (val1, val2);
SELECT SCOPE_IDENTITY()
, , @DbSql nvarchar, varchar.