Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I received this error while deploying a SQL Server DBProject

DBProj.dbschema(0,0): Warning SQL01271: The unnamed foreign key between tables [dbo].[Match] and [dbo].[Team] will be checked by checking the table. Name the foreign key to avoid checking the entire table and only check the new constraint.

My table definition is

CREATE TABLE [dbo].[Match]
(
    MatchID         int identity(11,2) PRIMARY KEY, 
    TournamentID    int not null REFERENCES Tournament(TournamentID),
    Team1_ID        int not null REFERENCES Team(TeamID),
    Team2_ID        int not null REFERENCES Team(TeamID),
    MatchDate       date,
    MatchTime       time
)

What does this error means? What is the implication?

update

actually, am concerned about the warning that it will check the entire table. Is it at creation time or every time? how does this affect performance?

share|improve this question
    
I tried your exact code and did not get any warnings! –  Emmad Kareem Aug 5 '12 at 20:39
    
It's from a DBProject created in visual studio. It helps manage the update of schema without dropping the tables. It resolves conflicts and display warnings like when "changing decimal to int" as "probably loss of precision" and the likes. This warning is one of such –  codingbiz Aug 5 '12 at 21:01
    
It advised that references/constraints should be named. –  codingbiz Aug 5 '12 at 21:02
    
Sounds interesting. Did you get the same result if you run the code from MSMS directly? I ran it from VS2010 and MSMS without warnings. This is strange. –  Emmad Kareem Aug 6 '12 at 7:56

1 Answer 1

up vote 2 down vote accepted

Try the more verbose syntax

...
Team1_ID int not null CONSTRAINT FK_Match_Team1 FOREIGN KEY (TeamID) REFERENCES Team (TeamID),
Team1_ID int not null CONSTRAINT FK_Match_Team2 FOREIGN KEY (TeamID) REFERENCES Team (TeamID),
...

I'd suggest the lack of explicit constraint name is confusing VS because you have 2 match-team constraints. That is, it is a Visual Studio error not a SQL Server error. You won't get it in SSMS

share|improve this answer
    
actually, am concerned about the warning that it will check the entire table. Is it at creation time or every time records are added –  codingbiz Aug 5 '12 at 11:59
    
@codingbiz: It will always happen when records are added or when Team records are deleted. However, VS could be braindead and check the entire table when you build or apply: I don't know because I use SSMS 100% for SQL Server work. It would seem unnecessary, but see "braindead"... –  gbn Aug 5 '12 at 12:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.