>>>I am using GUID values for all primary keys in an application. I am also using only stored procedures for all data access including inserts or updates. If I set newid() as the default of a column, then it gets added on insert. The question is how can I select back that row after the insert if I do not know the ID value? I suspect there is a means within a stored procedure insert to do this, but not sure of the function.
>>>
>>>If I was using incremented integers, I could use this I think.
>>>WHERE ([tablePK] = SCOPE_IDENTITY())
>>>
>>>What can I use for Guids?
>>>Thanks
>>
>>You need to return that new value using OUTPUT clause of the INSERT command.
>
>Hi Naomi,
>That makes sense and I will give that a test run. I want to return the entire row back.
>I appreciate it.
If you're using stored procedure and know the structure of your table, you will do
output inserted.Id, Inserted.Column1, Inserted.Column2, etc. -- to output the whole new row
If it's not broken, fix it until it is.
My Blog