TSQL – Getting New Primary Key

January 2, 2019
Been a ColdFusion Developer since 1996
Wizard 22 posts
Followers: 12 people
Web Developer
3

TSQL – Getting New Primary Key

Been a ColdFusion Developer since 1996
Wizard 22 posts
Followers: 12 people
January 2, 2019
Comments (3)
2019-01-08 21:44:02
2019-01-08 21:44:02

How about using <cfquery name=”myQuery” result=”myQuery_Result”> and then calling #myQuery_Result.generatedKey#?

Like
(2)
>
David Byers
's comment
2019-01-09 18:10:37
2019-01-09 18:10:37
>
David Byers
's comment

I tried to see if I could get to work. I made a query, but that field is not available in my result. It does not seem to be universally available.

https://stackoverflow.com/questions/40270744/the-generatedkey-value-is-missing-from-my-cfquery-result-structure

If it would have worked, I would have ran
SELECT top 100 deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time DESC
To see what query it did to get the results

~~~~

If someone gets this to work, I would like to know what it does.

 

 

 

 

 

 

 

Like
>
James Mohler
's comment
2019-01-15 20:32:31
2019-01-15 20:32:31
>
James Mohler
's comment

Interesting!

I’ve never experienced a problem getting the generatedKey to appear in the results, but apparently it can happen.  I’ve just never run across it.

Like
(1)
Add your comment