how do i solve this?

Nur Rohadatul Aisy Bte Rozmin 1 Reputation point
2020-06-04T17:09:29.033+00:00

/*Create College table */
Use SigmaUniversity;
GO

Create table College (
CollegeCode int not null,
CollegeName nvarchar(50) not null,
DeanFirstName nvarchar(50) not null,
DeanLastName nvarchar(50) not null,
DeanEmail nvarchar(50) not null,
Constraint CollegePK Primary key (CollegeCode),
Constraint CollegeNameValues check (CollegeName in ('College in Business', 'College of Engineering'))
);

/* Create table Department */
Create table Department (
DepartmentCode INT NOT NULL Primary Key,
DepartmentName NCHAR(50) NOT NULL,
CollegeCode INT not NULL,
CONSTRAINT FK_Department_College FOREIGN KEY (CollegeCode)
REFERENCES College,
Constraint DeptNameValue Check (DepartmentName in ('Accounting','Economics', 'Finance', 'Civil Engineering', 'Computer Engineering', 'Electronics Engineering'))
);

/*Create table Professor */
Create table Professor (
ProfessorCode INT NOT NULL Primary Key,
FirstName NCHAR (50) NOT NULL,
LastName NCHAR (50) NOT NULL,
Email NChar (50) NOT NULL,
DepartmentCode Int Not null,
CONSTRAINT FK_Prof_Dept FOREIGN KEY (DepartmentCode) REFERENCES Department
);

/*Create Student table */
Create table Student (
StudentCode int not null,
FirstName nvarchar(50) not null,
LastName nvarchar(50) not null,
Email nvarchar(50) not null,
RegisterDate date not null,
DepartmentCode int not null,
constraint StudentPK primary key (StudentCode),
constraint DepartmentFK2 foreign key (DepartmentCode)
references Department (DepartmentCode)
);

Error message:
There is already an object named 'College' in the database.

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vaibhav Chaudhari 38,576 Reputation points
    2020-06-04T19:41:12.627+00:00

    Error message: There is already an object named 'College' in the database.

    Looks like there is already a table named College in your database. Either rename it to Collect_bkp or drop it using query DROP TABLE College and then run your create table script


    If the response helped, do "Accept Answer" and upvote it - Vaibhav

    1 person found this answer helpful.
    0 comments No comments

  2. Poy Siraprapa 1 Reputation point
    2020-06-05T20:26:54.647+00:00

    Alt/Option+F10

    0 comments No comments