+ Reply to Thread
Results 1 to 3 of 3

Thread: SQL Table Query issue

  1. #1

    SQL Table Query issue

    This is my first time using SQL Server and I have created these tables:

    create table Department
        D_Number int not null,
        D_Name varchar(20),
        D_MgrSSN int,
        D_MgrDate datetime,
        primary key(D_Number),
    create table Empolyee
        E_SSN int not null,
        E_FName varchar(20),
        E_LName varchar(20),
        E_Sex varchar(6),
        E_BDate datetime,
        E_Salary decimal(10,2),
        E_Address varchar(50),
        E_Department varchar(20),
        E_SuperSSN int,
        primary key(E_SSN),
        foreign key(E_Department) references Department(D_Number),
    and when I run I get this error:

    Column 'Department.D_Number' is not the same data type as referencing column 'Empolyee.E_Department' in foreign key 'FK_Empolyee_E_Depa__0CBAE877'.
    Last edited by basemhosam; 01-07-2012 at 02:44 AM.

  2. #2
    This is because E_Department is varchar(20), but the column that it references, D_Number, is int. You need to make both of them the same type (int, because you called it "Number").

  3. #3
    oh thanks a lot , how come i did that mistake ? , thanks a lot for your help

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts