Problem with adding table

  • Hello

    I tried to add table with the following statement:

    CREATE TABLE MANAGER (FIRST_NAME nvarchar (50) ,ID int ,LAB_ID int ,LAST_NAME nvarchar (50) ,RESPONSIBILTY nvarchar (50) CONSTRAINT PK_MANAGER PRIMARY KEY (ID ) CONSTRAINT MANAGER FOREIGN KEY ( LAB_ID ) REFERENCES LAB ( ID ) ON DELETE CASCADE ON UPDATE CASCADE )

    and I gets the following error :

    Msg 2714, Level 16, State 4, Line 1

    There is already an object named 'MANAGER' in the database.

    Msg 1750, Level 16, State 0, Line 1

    Could not create constraint. See previous errors.

    :w00t:

    in spite of the fact that I can't see any such table in the database :crazy:

    Thanks

    Rachamim

  • The error says

    "There is already an object named 'MANAGER' in the database."

    So the object doesn't have to be a table. I suggest look in sys.objects

    for any objects with the name manager.

    [font="Verdana"]Markus Bohse[/font]

  • Is there any easy way to check it , there is a lot of object here

  • Hi,

    Here's an example query

    SELECT TABLE_NAME

    FROM INFORMATION_SCHEMA.tables

    Where table_name = Manager

    Thank you,

    Phillip

  • well, its not there, and I think that 'MANAGER' isn't a table

    is there any other place I can look for?

  • Hi,

    Run this in context of the database in question:

    select * from sysobjects

    where name like '%manager'

    and type = 'U'

    Thank you,

    Phillip Cox

  • I do so Philip but I got empty table as result

    Rachamim

  • Change the foreign key constraint name from MANAGER to FK_MANAGER.

  • Thank you very much Suresh B. its work:)

    indeed it was stupid mistake

    Rachamim

  • Welcome.

    Mistakes happen sometimes.

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply