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
SSCarpal Tunnel
SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)

Group: General Forum Members
Points: 4528 Visits: 2152
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
SSCertifiable
SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)

Group: General Forum Members
Points: 5886 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
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1045 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
SSCarpal Tunnel
SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)

Group: General Forum Members
Points: 4528 Visits: 2152
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 (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 3
Good Question.. thanks
Hardy21
Hardy21
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

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

Thanks
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (110K reputation)SSC Guru (110K reputation)SSC Guru (110K reputation)SSC Guru (110K reputation)SSC Guru (110K reputation)SSC Guru (110K reputation)SSC Guru (110K reputation)SSC Guru (110K reputation)

Group: General Forum Members
Points: 110258 Visits: 13338
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 (175 reputation)SSC-Enthusiastic (175 reputation)SSC-Enthusiastic (175 reputation)SSC-Enthusiastic (175 reputation)SSC-Enthusiastic (175 reputation)SSC-Enthusiastic (175 reputation)SSC-Enthusiastic (175 reputation)SSC-Enthusiastic (175 reputation)

Group: General Forum Members
Points: 175 Visits: 139
Good question! :-)
Michael Riemer
Michael Riemer
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3426 Visits: 665
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 Eights!
SSC Eights! (882 reputation)SSC Eights! (882 reputation)SSC Eights! (882 reputation)SSC Eights! (882 reputation)SSC Eights! (882 reputation)SSC Eights! (882 reputation)SSC Eights! (882 reputation)SSC Eights! (882 reputation)

Group: General Forum Members
Points: 882 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