<p>I inserted some values into a table. There is a column whose value is auto-generated. In the next statement of my code, I want to retrieve this value.</p>

<p>Can you tell me how to do it the right way?</p>

```
```
SELECT @@Scope_Identity as Id
```
```
There is also @@identity, but if you have a trigger, it will return the results of something that happened during the trigger, where scope_identity respects your scope.