<p>I'm using an SqlCommand object to insert a record into a table with an autogenerated primary key. How can I write the command text so that I get the newly created ID when I use the ExecuteScalar() method?</p>

```
```
insert into Yourtable()  
values()  
SELECT SCOPE_IDENTITY()
```
```
I just ran a test and verified that the semi-colons are optional using SQL Server 2005 SP2, and .Net 3.5