>OK. In SQL 2005, you can actually include the OUTPUT keyword into an INSERT statement.
>
>Here's an example that creates a table variable with an identity column, inserts a new row, and outputs the value of the identity column as a result set.
>
>You can also use the scope_identity that I mentioned before, or you can use this.
>
>
>DECLARE @tTestTable TABLE ( MyIdentityCol int IDENTITY, Name char(100))
>
>
>INSERT INTO @tTestTable
> OUTPUT Inserted.MyIdentityCol
> VALUES ('KEVIN')
>
>
>Note the reference to 'inserted'....this, along with 'deleted' were two system tables previously available only in insert/update triggers. They're now accessible during an insert/update statement/delete statement.
>
>Not trying to overload you, but figured it might be worth knowing down the road.
Thanks, this is very good. But, this approach requires the creation of a store procedure. As I don't want to create it, as this is done at run time, I need to have everything in the same command. So, for now, I am executing the SQL insert command. Then, after, on another command, I get the primary key. It is basically the same approach as I am using with the VFPOleDb provider which is using a two step approach. Unless you know a way to execute that code as is without having to create anything on disk or in the SQL Server database.