SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Fun with IDENTITY - Part II


Fun with IDENTITY - Part II

Author
Message
Nakul Vachhrajani
Nakul Vachhrajani
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2256 Visits: 2145
Comments posted to this topic are about the item Fun with IDENTITY - Part II

Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Be courteous. Drive responsibly.

Follow me on
Twitter: @sqltwins
Google Plus: +Nakul
UMG Developer
UMG Developer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2688 Visits: 2204
Nice question, thanks!

Related BOL links:

SQL Server 2008 R2: http://msdn.microsoft.com/en-us/library/ms175010.aspx
SQL Server 2008: http://msdn.microsoft.com/en-us/library/ms175010(SQL.100).aspx
SQL Server 2005: http://msdn.microsoft.com/en-us/library/ms175010(SQL.90).aspx
SQL Server 2000: http://msdn.microsoft.com/en-us/library/aa260638(SQL.80).aspx

All of them say:
* "Transactions involving table variables last only for the duration of an update on the table variable. Therefore, table variables require less locking and logging resources."
* "... because table variables have limited scope and are not part of the persistent database, they are not impacted by transaction rollbacks."

I think that pretty much says that table variables don't fully participate in transactions, and can't be rolled back. (I was expecting to find something that said variables don't participate in transactions, but I never found that.)
Dhruvesh Shah
Dhruvesh Shah
SSChasing Mays
SSChasing Mays (655 reputation)SSChasing Mays (655 reputation)SSChasing Mays (655 reputation)SSChasing Mays (655 reputation)SSChasing Mays (655 reputation)SSChasing Mays (655 reputation)SSChasing Mays (655 reputation)SSChasing Mays (655 reputation)

Group: General Forum Members
Points: 655 Visits: 237
Good Question.

I found this link on google which explains it bit more in details
http://www.sql-server-performance.com/articles/per/temp_tables_vs_variables_p1.aspx
Nakul Vachhrajani
Nakul Vachhrajani
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2256 Visits: 2145
UMG Developer (10/5/2010)
Nice question, thanks!

Related BOL links:

SQL Server 2008 R2: http://msdn.microsoft.com/en-us/library/ms175010.aspx
SQL Server 2008: http://msdn.microsoft.com/en-us/library/ms175010(SQL.100).aspx
SQL Server 2005: http://msdn.microsoft.com/en-us/library/ms175010(SQL.90).aspx
SQL Server 2000: http://msdn.microsoft.com/en-us/library/aa260638(SQL.80).aspx

All of them say:
* "Transactions involving table variables last only for the duration of an update on the table variable. Therefore, table variables require less locking and logging resources."
* "... because table variables have limited scope and are not part of the persistent database, they are not impacted by transaction rollbacks."

I think that pretty much says that table variables don't fully participate in transactions, and can't be rolled back. (I was expecting to find something that said variables don't participate in transactions, but I never found that.)


Thanks for your support and providing the great links.

I believe I could not get the supporting documentation for this question because I was looking for a reference to the fact that "variables don't participate in transactions" :-)

Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Be courteous. Drive responsibly.

Follow me on
Twitter: @sqltwins
Google Plus: +Nakul
manjul.dube
manjul.dube
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 3
Good Question.. thanks
Hardy21
Hardy21
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1582 Visits: 1399
Thanks 'UMG Developer' for reference links & Nakul for good question.

Thanks
Koen Verbeeck
Koen Verbeeck
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27391 Visits: 13268
Great question! Definately learned something today.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
larsts
larsts
SSC-Enthusiastic
SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)

Group: General Forum Members
Points: 173 Visits: 139
Good question! :-)
Michael Riemer
Michael Riemer
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2838 Visits: 639
Great question and thanks for the reference documentation. Nearly missed the fact that you were loading a table variable!!!

It is something I have used myself on occasions to manage logging, if we do a standard rollback, the logging is rolled back as well, so tracing records was impossible unless we logged to a table variable in the transaction. Once the transaction is rolled back or commited, the logging is stored into a fixed table.
COOL_ICE
COOL_ICE
SSC-Addicted
SSC-Addicted (416 reputation)SSC-Addicted (416 reputation)SSC-Addicted (416 reputation)SSC-Addicted (416 reputation)SSC-Addicted (416 reputation)SSC-Addicted (416 reputation)SSC-Addicted (416 reputation)SSC-Addicted (416 reputation)

Group: General Forum Members
Points: 416 Visits: 431
I got it worng no dought it is a good question :-)

- SAMJI
If you marry one they will fight with you, If you marry 2 they will fight for you :-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search