Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Primary Key Culstered

Author  Topic 

wsilage
Yak Posting Veteran

82 Posts

Posted - 2015-02-06 : 07:50:35
I have a question Right now we have 2 tables one table is called Regions and within that table we have this

ID Name
221 0221_ms
224 0224_tu
226 0226_ar

Our other table has this and the name of that table is called Regionstates.

ID Name
221 AZ
224 LA
226 CT

Now they want to change the names of the users that get the IDs from the first table to.

ID Name
224 0221_ms
226 0224_tu
221 0226_ar


My questions is and I never delt with Primary key clustered before.

If I change the above, will that affect anyting? Also I was thinking of making the names a little more generic

I was thinking of labeling them.

ID Name
224 Region1
226 Region2
221 Region3


Would this mess up my table? Like I said I have never used clusters before see sample

This is the Region States table


CREATE TABLE [dbo].[RegionStates](
[RegionID] [smallint] NOT NULL,
[State] [char](2) NOT NULL,
CONSTRAINT [PK_RegionStates] PRIMARY KEY CLUSTERED
(
[RegionID] ASC,
[State] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[RegionStates] WITH CHECK ADD CONSTRAINT [FK_RegionStates_Regions] FOREIGN KEY([RegionID])
REFERENCES [dbo].[Regions] ([ID])
GO

ALTER TABLE [dbo].[RegionStates] CHECK CONSTRAINT [FK_RegionStates_Regions]
GO

ALTER TABLE [dbo].[RegionStates] WITH CHECK ADD CONSTRAINT [FK_RegionStates_USStates] FOREIGN KEY([State])
REFERENCES [dbo].[USStates] ([StateCode])
GO

ALTER TABLE [dbo].[RegionStates] CHECK CONSTRAINT [FK_RegionStates_USStates]
GO




This is the Region table

CREATE TABLE [dbo].[RegionsTEST](
[ID] [smallint] NOT NULL,
[Name] [varchar](50) NOT NULL,
CONSTRAINT [PK_Regions] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2015-02-06 : 08:21:42
You wanted to update the data based on your requirement.. thats it right?

So no need to worry about CLUSTERED PRIMARY KEYs....

--
Chandu
Go to Top of Page

wsilage
Yak Posting Veteran

82 Posts

Posted - 2015-02-06 : 08:43:45

quote:
Originally posted by bandi

You wanted to update the data based on your requirement.. thats it right?

So no need to worry about CLUSTERED PRIMARY KEYs....

--
Chandu



Yes I want to update the base table which. Thanks so much!
Go to Top of Page
   

- Advertisement -