July 31, 2023 at 12:00 am
Comments posted to this topic are about the item What will be inserted?
July 31, 2023 at 9:50 pm
I'm going to call my answer of "We can't guess" correct. The reason being, without knowing the structure of your table, we cannot possibly know the output of the INSERT statement. What if the "mytime" column was declared NOT NULL? Then the result would be an error.
July 31, 2023 at 9:52 pm
When in doubt, assume the columns exist and defaults are used. NULL is the default.
August 2, 2023 at 8:16 am
I also think "We can't guess" is correct, but for a different reason. Rows could have been inserted by other users in the time between the insert statement and the query being executed. There could also have been failed attempts to insert during that period.
August 2, 2023 at 3:49 pm
No, not a valid guess. There are always potential issues with concurrency, but for understanding the point, which is what is reflected in system tables and what happens, you ought to be able to determine this. For some systems and some data, the next value is stored, for some the last value. Knowing which is which is helpful.
August 10, 2023 at 2:58 pm
What about if the server or sql service was restarted since the last insert and the cached identity values were tossed out? Wouldn't the value in sys.identity_columns still be the last value that was inserted (or attempted) but the next value be much higher?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 10, 2023 at 5:03 pm
There are always holes. It is very difficult or not impossible to write questions to cover every certainty. Assume this ran and the value was something you checked in the nanosecond before an insert.
August 10, 2023 at 6:25 pm
There are always holes. It is very difficult or not impossible to write questions to cover every certainty. Assume this ran and the value was something you checked in the nanosecond before an insert.
Agreed 10000% that it is impossible to write a short question that covers all the loopholes. I chose "we can't guess" because it is not always a reliable value. To be honest I didn't even realize until today this column existed. Just never paid attention to it I guess.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply