ADDING A PRIMARY KEY
From: Konstantinos Michas (anonymous_at_discussions.microsoft.com)
Date: 05/03/04
- Next message: Art: "sp_send_cdosysmail truncates @body"
- Previous message: Prabhat: "Re: BULK Insert Problem"
- Next in thread: Tibor Karaszi: "Re: ADDING A PRIMARY KEY"
- Reply: Tibor Karaszi: "Re: ADDING A PRIMARY KEY"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 3 May 2004 02:34:33 -0700
Hello Experts,
I'm a little bit confused about what happening with these
queries.
I'm trying to add a priamary key on my table. The First
Set of queries do not do that, the Second Set does that,
the funny thing is that I don't see a serious reason not
adding my PK with 1st Set of qureies.
--1st
CREATE TABLE Constraints(DB nvarchar(50), Tbl nvarchar
(50), ConsName nvarchar(100), ConsType nvarchar(50), Cons
nvarchar(500)) ON [PRIMARY]
GO
ALTER TABLE dbo.[Constraints] WITH NOCHECK ADD
CONSTRAINT [PK_Constraints] PRIMARY KEY CLUSTERED
([DB],
[Tbl],
[ConsName]
) ON [PRIMARY]
GO
--2nd
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[Constraints]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[Constraints]
GO
CREATE TABLE [dbo].[Constraints] (
[DB] [nvarchar] (50) COLLATE
SQL_Latin1_General_CP1253_CS_AS NOT NULL ,
[Tbl] [nvarchar] (50) COLLATE
SQL_Latin1_General_CP1253_CS_AS NOT NULL ,
[ConsName] [nvarchar] (100) COLLATE
SQL_Latin1_General_CP1253_CS_AS NOT NULL ,
[ConsType] [nvarchar] (50) COLLATE
SQL_Latin1_General_CP1253_CS_AS NULL ,
[Cons] [nvarchar] (500) COLLATE
SQL_Latin1_General_CP1253_CS_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Constraints] WITH NOCHECK ADD
CONSTRAINT [PK_Constraints] PRIMARY KEY
CLUSTERED
(
[DB],
[Tbl],
[ConsName]
) ON [PRIMARY]
GO
Thanks in advance!
- Next message: Art: "sp_send_cdosysmail truncates @body"
- Previous message: Prabhat: "Re: BULK Insert Problem"
- Next in thread: Tibor Karaszi: "Re: ADDING A PRIMARY KEY"
- Reply: Tibor Karaszi: "Re: ADDING A PRIMARY KEY"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|