Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    133

    Unanswered: Newbie need help:establishing a relationship

    I have a simle question for you:
    I created a employee table:

    create table employees (
    employeeid int primary key,
    lastname nvarchar(20) not null,
    firstname nvarchar(20) not null,
    birthdate datetime,
    city nvarchar(15),
    country nvarchar(15)
    )

    and then I created table orders and established a relationship between them:

    create table orders (
    orderid int primary key,
    employeeid int references employees(employeeid),
    orderdate datetime
    )

    The relationship was created successfully.

    But I don't know how to establish a relationship between two tables if they were already exist.
    Could you tell me how to do it?
    many thanks

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    ALTER TABLE foo ADD CONSTRAINT should do the trick.

    -PatP

  3. #3
    Join Date
    May 2004
    Posts
    133
    thanks. it works for me

Posting Permissions

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