Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by bitbucket
»
T-SQL Output Clause
37 posts, Page 2 of 4
««
1
2
3
4
»
»»
T-SQL Output Clause
Rate Topic
Display Mode
Topic Options
Author
Message
core-909671
core-909671
Posted Wednesday, January 06, 2010 5:59 AM
Grasshopper
Group: General Forum Members
Last Login: Thursday, December 02, 2010 8:45 AM
Points: 14,
Visits: 116
The temporary table does not contain a column "CategoryName". It attempts to update a column that does not exist. It would throw an error, not return rows.
Post #842707
john.curran.z3g
john.curran.z3g
Posted Wednesday, January 06, 2010 6:15 AM
SSC Veteran
Group: General Forum Members
Last Login: Monday, February 18, 2013 7:25 AM
Points: 236,
Visits: 53
IF you have Northwind installed, the statement will update a Northwind Categories table and use the values from the inserted/deleted OUTPUT option to insert into the temp table.
Post #842712
Lynn Pettis
Lynn Pettis
Posted Wednesday, January 06, 2010 6:36 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
Rich Holt (1/6/2010)
I should also caution you about the other way to look at this:
If you insert/update/delete TABLE variable rows inside a transaction, and subsequently rollback the work, the
table variable changes are not rolled back with the transaction
. This could lead to data inconsistencies.
Be careful.
I agree, be careful; however, there may be a reason that you want the output from the insert/update/delete regardless of the success/failure of the transactions. If this is the case, then using table variables is required.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #842734
Lynn Pettis
Lynn Pettis
Posted Wednesday, January 06, 2010 6:39 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
mjohnson-909671 (1/6/2010)
The temporary table does not contain a column "CategoryName". It attempts to update a column that does not exist. It would throw an error, not return rows.
Take a closer look at the code. CategoryName is being updated in the Categories table. The OUTPUT clause is inserting the Old and New Category names into a temporary table as an audit of changes.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #842736
core-909671
core-909671
Posted Wednesday, January 06, 2010 6:41 AM
Grasshopper
Group: General Forum Members
Last Login: Thursday, December 02, 2010 8:45 AM
Points: 14,
Visits: 116
Ah. Ok. I don't have Northwind installed anywhere.
Post #842738
Lynn Pettis
Lynn Pettis
Posted Wednesday, January 06, 2010 6:45 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
Neither do I.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #842741
dmbaker
dmbaker
Posted Wednesday, January 06, 2010 7:07 AM
Mr or Mrs. 500
Group: General Forum Members
Last Login: Today @ 6:42 AM
Points: 504,
Visits: 2,530
Where was the choice for "Could not locate entry in sysdatabases for database 'Northwind'."?
Post #842762
Lynn Pettis
Lynn Pettis
Posted Wednesday, January 06, 2010 7:23 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
dmbaker (1/6/2010)
Where was the choice for "Could not locate entry in sysdatabases for database 'Northwind'."?
Actually irrelevant to answering the question.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #842786
dmbaker
dmbaker
Posted Wednesday, January 06, 2010 7:29 AM
Mr or Mrs. 500
Group: General Forum Members
Last Login: Today @ 6:42 AM
Points: 504,
Visits: 2,530
I know, I got the question right. Just being snarky.
Post #842793
core-909671
core-909671
Posted Wednesday, January 06, 2010 7:39 AM
Grasshopper
Group: General Forum Members
Last Login: Thursday, December 02, 2010 8:45 AM
Points: 14,
Visits: 116
Gee.thanks. First time I ever post... thanks a ton. You're the best!
Post #842803
« Prev Topic
|
Next Topic »
37 posts, Page 2 of 4
««
1
2
3
4
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.