locked
Foriegn Key error question RRS feed

  • Question

  • I am not a DBA, but have been given the job of creating some foreign keys in our database...because we don't have a DBA,.  So in SQL Server management studio when I open a table in design view, I can create a relationship(foreign key) and when I try to save the design I get the following error:

    I don't however get an error when I add the foreign key through an SQL statement like:

    ALTER TABLE [dbo].[Addresses] ADD CONSTRAINT [FK_Addresses_Counties] FOREIGN KEY ([CountyId]) REFERENCES [dbo].[Counties] ([CountyId]) .

    The rowguid column is a uniqueidentifier.

    I'm trying to find out what I am doing wrong (if anything) while adding the relationship through SQL Management Studio Relationships, and/or, should I be concerned about that error if it creates and saves the relationship foreign key.

    Any help would be appreciated.  Thanks in advance.

    Friday, March 2, 2018 4:19 PM

Answers

  • This is a bug in the designer that is not being fixed by microsoft.
    Friday, March 2, 2018 4:34 PM
  • The error message suggests that you have a default tied to some column and the value that your default generates is "weird" according to the data type. This has nothing to do with what *you* are doing, but since the GUI will re-create the table, it will also re-create that faulty default. So, the error message suggests that the problem is not what what you are doing, but with what somebody before you has done.

    Or, it could just be a bug in the GUI (with the same effect).


    Tibor Karaszi, SQL Server MVP (Web Blog)

    Monday, March 5, 2018 12:30 PM

All replies

  • do you get the same error while doing this through TSQL
    Friday, March 2, 2018 4:30 PM
  • No I don't
    Friday, March 2, 2018 4:34 PM
  • This is a bug in the designer that is not being fixed by microsoft.
    Friday, March 2, 2018 4:34 PM
  • The error message suggests that you have a default tied to some column and the value that your default generates is "weird" according to the data type. This has nothing to do with what *you* are doing, but since the GUI will re-create the table, it will also re-create that faulty default. So, the error message suggests that the problem is not what what you are doing, but with what somebody before you has done.

    Or, it could just be a bug in the GUI (with the same effect).


    Tibor Karaszi, SQL Server MVP (Web Blog)

    Monday, March 5, 2018 12:30 PM