#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    Need Help, cant figure out where I am going wrong


    I have been working on this for my class for the past week. I cant figure out how to fix the last few errors. Any suggestions.



    create database [University_WK]
    go
    use [University_WK]
    go
    create table dbo.STUDENT(
    StudentName varchar (50)
    )
    go
    alter table Student
    add StudentID varchar (50) not null
    go
    alter table Student
    add constraint PK_Student PRIMARY KEY (StudentID)
    go
    insert dbo.STUDENT (StudentName, StudentID) Values ('Letersky','38214')
    go
    insert dbo.STUDENT (StudentName, StudentID) Values ('Altvater','54907')
    go
    insert dbo.STUDENT (StudentName, StudentID) Values ('Aiken','66324')
    go
    insert dbo.STUDENT (StudentName, StudentID) Values ('Marra','70542')
    go
    exec sp_rename 'Student.StudentName','LastName'
    go
    alter table Student
    add FirstName Varchar(50)
    go
    update student
    set FirstName = 'Sarah'
    Where StudentID = 38214
    go
    update student
    set FirstName = 'Bill'
    Where StudentID = 54907
    go
    update student
    set FirstName = 'Lexi'
    Where StudentID = 66324
    go
    update student
    set FirstName = 'Mia'
    Where StudentID = 70542
    go
    alter table Student
    add FullName Varchar (100)
    go
    update STUDENT
    set FullName = FirstName + ' ' + LastName
    go
    create table dbo.FACULTY(
    FacultyID varchar (50),
    FacultyName varchar (50),
    constraint PK_FACULTY Primary Key (FacultyID)
    )
    go
    create table dbo.COURSE(
    CourseID varchar (50),
    CourseName varchar (50),
    constraint PK_COURSE Primary Key (CourseID)
    )
    go
    create table dbo.QUALIFIED(
    FacultyID varchar (50),
    CourseID varchar (50),
    DateQualified varchar (50),
    constraint PK_QUALIFIED Primary Key (FacultyID, CourseID),
    constraint FK_QUALIFIED_FACULTY
    foreign key (FacultyID) references FACULTY (FacultyID)
    on delete cascade on update cascade,
    constraint FK_QUALIFIED_COURSE
    foreign key (CourseID) references COURSE (CourseID)
    on delete no action on update cascade,
    )
    go
    create table dbo.SECTION(
    SectionNo varchar (50),
    Semester varchar (50),
    CourseID varchar (50),
    constraint PK_SECTION Primary Key (SectionNo, Semester, CourseID),
    constraint FK_SECTION_COURSE
    foreign key (CourseID) references COURSE (CourseID)
    on delete cascade on update cascade,
    )
    go
    create table dbo.REGISTRATION(
    StudentID varchar (50) not null,
    SectionNo varchar (50),
    Semester varchar (50),
    constraint PK_REGISTRATION Primary Key (StudentID, SectionNo, Semester),
    constraint FK_REGISTRATION_STUDENT
    foreign key (StudentID) references STUDENT (StudentID)
    on delete cascade on update cascade,
    constraint FK_REGISTRATION_SECTION
    foreign key (SectionNo) references SECTION (SectionNo)
    on delete no action on update cascade,
    )
    go
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,209
    Rep Power
    4279
    you neglected to mention the errors, but i can see you have a few dangling commas before closing parentheses
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo