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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 DEV QA PRD

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2008-07-07 : 12:54:06
Greetings

Place I am working at has just implemented SQL 2005. One SQL server where the IT department uses it for both development work and also production, meaning software developers use it to develop and users use it to do actual live production work. I know it is very scary.
I want to create a DEV environment on this same box by creating a new database with DEV suffix. I haev scripted out everything and ran it succesfully on the DEV database. Problem is when trying to recreate constraints
ALTER TABLE [dbo].[JobSignOff] WITH CHECK ADD CONSTRAINT [fk_JobSignOffJobID_JobsJobID] FOREIGN KEY([JobID])
REFERENCES [dbo].[Jobs] ([JobID]) I get following error? What is it talkign about ?
There are no primary or candidate keys in the referenced table 'dbo.Jobs' that match the referencing column list in the foreign key 'fk_JobSignOffJobID_JobsJobID'.

Thanks!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-07 : 13:54:54
Do you have a primary key column named JobID in Jobs table? it says it cant find such a primary key column.
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2008-07-07 : 16:00:10
Yes I do have a primary key called JobID INDENTITY(1,1). Could the problem be that a similar constraint already exist in my "PRD" database or in master database?

Thanks
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2008-07-07 : 19:46:56
Could it be that the scripts are not being run in the necessary order? It sounds like the Jobs table needs to be created and have its unique/primary key defined before you create the foreign key from the JobSignOff table. This might be true on the PRD database but does it also hold true in your DEV environment?

Also, the constraints defined in the PRD database have no impact on the DEV database.

HTH

=======================================
Some people walk in the rain, others just get wet. -Roger Miller, musician (1936-1992)
Go to Top of Page
   

- Advertisement -