Tuesday, March 20, 2012

Primary key clustered with / without constraint (question)

HI,
I have some difficulty to understand the difference bettween those to
statements.
When do we specify "constraint" and when we don't need to ?
What is the pro and con of specifying "contraint"
Does anyone can guide me ?
ALTER TABLE [dbo].[AB000_table_name] WITH NOCHECK
ADD
PRIMARY KEY CLUSTERED

ALTER TABLE [dbo].[AB000_table_name] WITH NOCHECK
ADD CONSTRAINT [PK__AB000_field__07C12930]
PRIMARY KEY CLUSTERED
Thank you
Danny
Hi,
When do we specify "constraint" and when we don't need to ?
If you specifiy CONSTRAINT we can give our own contrain names, otherwise
system will generate its own contrain name starting with (PK_TABLENAME...)
What is the pro and con of specifying "contraint"?
There is no majour diffrence apart form name definition. (NO Pros and cons-
both are same)
Thanks
Hari
MCDBA
"Danny Presse" <DannyP@.congresmtl-NO-SPAM.com> wrote in message
news:eAq$ZEGOEHA.3380@.TK2MSFTNGP11.phx.gbl...
> HI,
> I have some difficulty to understand the difference bettween those to
> statements.
> When do we specify "constraint" and when we don't need to ?
> What is the pro and con of specifying "contraint"
> Does anyone can guide me ?
>
> ALTER TABLE [dbo].[AB000_table_name] WITH NOCHECK
> ADD
> PRIMARY KEY CLUSTERED
>
> ----
--
> --
> ALTER TABLE [dbo].[AB000_table_name] WITH NOCHECK
> ADD CONSTRAINT [PK__AB000_field__07C12930]
> PRIMARY KEY CLUSTERED
>
> Thank you
>
> Danny
>

No comments:

Post a Comment