Showing posts with label constraint. Show all posts
Showing posts with label constraint. Show all posts

Thursday, March 29, 2012

Does SQL Server check for constraint violation when COMMIT is called?

If there are two different transactions, both of which update the username column to 'xyz' for userid = 234 in 'Users' table. This is a unique value for username. Ater this update each transaction adds a row to 'AppLog' table. The transaction is only committed after second operation.

The 'username' column has a unique constraint on it.

If transaction isolation level is 'read committed', and both transaction execute the first operation when neither of the transactions have been committed, then the transaction that calls COMMIT later will error out or not? If COMMIT does not check constraints then it will NOT error out. As a result we will have a violation of unique constraint happening without any error being thrown by SQL Server.

sun21170:

If COMMIT does not check constraints then it will NOT error out.

The statements that COMMIT causes to execute will be checked for contraint violations. If SQL Server allowed constraint violations, it wouldn't be around very long.

sql

Friday, February 24, 2012

Does a FK constraint create an index?

(SQL Server 2000, SP3a)
Hello all!
I was wondering if a foreign key constraint will create an index like a prim
ary key
constraint?
Thanks!
John PetersonNope.
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"John Peterson" <j0hnp@.comcast.net> wrote in message
news:eG2RnlF3DHA.1720@.TK2MSFTNGP10.phx.gbl...
(SQL Server 2000, SP3a)
Hello all!
I was wondering if a foreign key constraint will create an index like a
primary key
constraint?
Thanks!
John Peterson|||Nope, you'll have to build one yourself.
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"John Peterson" <j0hnp@.comcast.net> wrote in message
news:eG2RnlF3DHA.1720@.TK2MSFTNGP10.phx.gbl...
quote:

> (SQL Server 2000, SP3a)
> Hello all!
> I was wondering if a foreign key constraint will create an index like a

primary key
quote:

> constraint?
> Thanks!
> John Peterson
>
|||Thanks Tom/Kalen! That's what I thought -- but wanted to double-check, as t
he CREATE
TABLE entry in BOL wasn't wholly specific on whether an index was created in
the PK
context (though, it alludes to it later), and I thought maybe the FK descrip
tion was
potentially similarly vague.
Thanks again!
John Peterson
"John Peterson" <j0hnp@.comcast.net> wrote in message
news:eG2RnlF3DHA.1720@.TK2MSFTNGP10.phx.gbl...
quote:

> (SQL Server 2000, SP3a)
> Hello all!
> I was wondering if a foreign key constraint will create an index like a pr
imary key
> constraint?
> Thanks!
> John Peterson
>

Does a FK constraint create an index?

(SQL Server 2000, SP3a)
Hello all!
I was wondering if a foreign key constraint will create an index like a primary key
constraint?
Thanks!
John PetersonThis is a multi-part message in MIME format.
--=_NextPart_000_0071_01C3DC30.22A93000
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
Nope.
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"John Peterson" <j0hnp@.comcast.net> wrote in message
news:eG2RnlF3DHA.1720@.TK2MSFTNGP10.phx.gbl...
(SQL Server 2000, SP3a)
Hello all!
I was wondering if a foreign key constraint will create an index like a
primary key
constraint?
Thanks!
John Peterson
--=_NextPart_000_0071_01C3DC30.22A93000
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Nope.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"John Peterson" wrote in =message news:eG2RnlF3DHA.1720=@.TK2MSFTNGP10.phx.gbl...(SQL Server 2000, SP3a)Hello all!I was wondering if a foreign =key constraint will create an index like a primary keyconstraint?Thanks!John =Peterson

--=_NextPart_000_0071_01C3DC30.22A93000--|||Nope, you'll have to build one yourself.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"John Peterson" <j0hnp@.comcast.net> wrote in message
news:eG2RnlF3DHA.1720@.TK2MSFTNGP10.phx.gbl...
> (SQL Server 2000, SP3a)
> Hello all!
> I was wondering if a foreign key constraint will create an index like a
primary key
> constraint?
> Thanks!
> John Peterson
>|||Thanks Tom/Kalen! That's what I thought -- but wanted to double-check, as the CREATE
TABLE entry in BOL wasn't wholly specific on whether an index was created in the PK
context (though, it alludes to it later), and I thought maybe the FK description was
potentially similarly vague.
Thanks again!
John Peterson
"John Peterson" <j0hnp@.comcast.net> wrote in message
news:eG2RnlF3DHA.1720@.TK2MSFTNGP10.phx.gbl...
> (SQL Server 2000, SP3a)
> Hello all!
> I was wondering if a foreign key constraint will create an index like a primary key
> constraint?
> Thanks!
> John Peterson
>