January 11, 2010 at 11:49 pm
Comments posted to this topic are about the item Session Settings
January 11, 2010 at 11:50 pm
This was removed by the editor as SPAM
January 12, 2010 at 12:09 am
Thanks for another question bitbucket. Had to use the noggin on this one a bit.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 12, 2010 at 2:22 am
Thanks bitbucket for a nice question i learnt lot from this....
January 12, 2010 at 5:02 am
Slight problem, I think the question is incomplete:
1. In the text the table is referred to 'QOD_Customer' (singular), but in the SQL it is 'QOD_Customers' (plural)
2. There is no mention of the CompanyName column in the question.
January 12, 2010 at 7:14 am
The table name has been corrected. A complete DDL is not given. You should assume other fields mentioned do exist, but are not listed for brevity.
January 12, 2010 at 7:48 am
Nice question, took some thought. Thanks.
January 12, 2010 at 8:07 am
January 12, 2010 at 8:23 am
Can someone verify for me that this is different in SQL 2008 vs SQL 2005? I get a different result using 2005 (I don't have access to a 2008 server).
Thanks!
January 12, 2010 at 8:42 am
Ernie Schlangen (1/12/2010)
Can someone verify for me that this is different in SQL 2008 vs SQL 2005? I get a different result using 2005 (I don't have access to a 2008 server).Thanks!
It appears that you should get the same result on SQL 2005 as SQL 2008.
January 12, 2010 at 9:26 am
Ernie Schlangen
Can someone verify for me that this is different in SQL 2008 vs SQL 2005? I get a different result using 2005 (I don't have access to a 2008 server).
Just ran in SQL 2005 Developer Edition - same results
January 12, 2010 at 9:29 am
Thanks, I must have skipped something. At work now, will try again later. Thanks again!
January 12, 2010 at 9:46 am
Cliff Jones (1/12/2010)
Ernie Schlangen (1/12/2010)
Can someone verify for me that this is different in SQL 2008 vs SQL 2005? I get a different result using 2005 (I don't have access to a 2008 server).Thanks!
It appears that you should get the same result on SQL 2005 as SQL 2008.
I'm with Ernie on this. The rollback worked on 2005.
DDL and data inserted:
--drop table [QOD_Customers]
create table [dbo].[QOD_Customers](
ID int Identity
,[CompanyName] nChar(10)
,[Region] nChar(3) Null
)
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('ABC','YYY')
insert into [QOD_Customers] (CompanyName,Region) values('XYX', null)
insert into [QOD_Customers] (CompanyName,Region) values('XYX', null)
insert into [QOD_Customers] (CompanyName,Region) values('XYX', null)
insert into [QOD_Customers] (CompanyName,Region) values('XYX', null)
insert into [QOD_Customers] (CompanyName,Region) values('XYX', null)
Create stored procedure:
--drop procedure [QOD_Test_1]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[QOD_Test_1]
AS
SET ANSI_DEFAULTS ON
-- Before rollback Select Statement
SELECT COUNT(CompanyName) AS 'Before rollback'
FROM [dbo].[QOD_Customers]
WHERE [dbo].[QOD_Customers].[Region] IS NULL
UPDATE Dbo.QOD_Customers
SET Region = 'XXX'
WHERE dbo.QOD_Customers.region IS NULL
-- The after update Select Statement
SELECT COUNT(CompanyName) AS 'After update'
FROM [dbo].[QOD_Customers]
WHERE [dbo].[QOD_Customers].[Region] IS NULL
ROLLBACK TRANSACTION
SET ANSI_DEFAULTS OFF
-- The after rollback Select Statement
SELECT COUNT(CompanyName) AS 'After Rollback'
FROM [dbo].[QOD_Customers]
WHERE [dbo].[QOD_Customers].[Region] IS NULL
GO
Run it:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_DEFAULTS ON
go
[dbo].[QOD_Test_1]
go
Results:
Before rollback
---------------
5
(1 row(s) affected)
(5 row(s) affected)
After update
------------
0
(1 row(s) affected)
After Rollback
--------------
5
(1 row(s) affected)
January 13, 2010 at 2:10 am
When ANSI_DEFAULTS is enabled (ON), this option enables the following ISO settings:...SET IMPLICIT_TRANSACTIONS. Msg 3903 The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
The explanation doesn't quite make sense - I presume there are some words missing somewhere? Or is the quoting of the error message just assumed to be for information purposes? The explanation makes it look like it's one of the ISO settings 🙂
-------------------------------Oh no!
January 13, 2010 at 6:49 am
Kevin Gill
From
SQL Server 2008 Books Online (November 2009)
SET ANSI_DEFAULTS (Transact-SQL)
AT:
http://msdn.microsoft.com/en-us/library/ms188340.aspx
When enabled (ON), this option enables the
In my explanation all I did was add the words "SET IMPLICIT_TRANSACTIONS" to the above quoted phrase.
the quoting of the error message just assumed to be for information purposes?
Yes it is.
Hope this clarifies it for you.
Viewing 15 posts - 1 through 15 (of 20 total)
You must be logged in to reply to this topic. Login to reply