When you insert a row to a table which has an identity field, you don't mention this field in the insert statement at all. For example, you have a table with two columns:
- Id (identity)
- Name (varchar)
The insert statement could look like
INSERT INTO INTO TableName (Name) VALUES ('Some name');
After the insert you can use SCOPE_IDENTITY
] to get the value of the inserted Id so you can use the value for a foreign key in some other insert into a child table.