Question

This script isn't working with SQL Server 2012, It keeps giving me an error of: There...

This script isn't working with SQL Server 2012, It keeps giving me an error of: There is already an object named 'CustomerID' in the database.

PLEASE HELP- What do I need to do?????

CREATE TABLE [CustomerID] (
[CustomerID] int,
[LastName] varchar(25),
[FirstName] varchar(25),
[PhoneNumber] varchar(10),
[Address] varchar(75),
[City] varchar(25),
[Zip] int,
[ServiceTicketID] int,
PRIMARY KEY ([CustomerID])
);

CREATE INDEX [FK] ON [CustomerID] ([ServiceTicketID]);

CREATE TABLE [ServiceTicket] (
[ServiceTicketID] int,
[DateOfService] varchar(25),
[Notes] varchar(100),
[CustomerID] int,
[PartsUsedID] int,
PRIMARY KEY ([ServiceTicketID])
);

CREATE INDEX [FK] ON [ServiceTicket] ([CustomerID], [PartsUsedID]);

CREATE TABLE [PartsUsed] (
[PartsUsedID] int,
[PartID] int,
[PriceOfPart] int,
[NumberOfPartsUsed] int,
[CustomerID] int,
[ServiceTicketID] int,
PRIMARY KEY ([PartsUsedID])
);

CREATE INDEX [FK] ON [PartsUsed] ([CustomerID], [ServiceTicketID]);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

DROP TABLE IF EXISTS Customer;

DROP TABLE IF EXISTS ServiceTicket;

DROP TABLE IF EXISTS PartsUsed;

CREATE TABLE [Customer] (

    [CustomerID] int,

    [LastName] varchar(25),

    [FirstName] varchar(25),

    [PhoneNumber] varchar(10),

    [Address] varchar(75),

    [City] varchar(25),

    [Zip] int,

    [ServiceTicketID] int,

    PRIMARY KEY ([CustomerID])

);

CREATE INDEX [Customer_FK] ON [Customer] ([ServiceTicketID]);

CREATE TABLE [ServiceTicket] (

    [ServiceTicketID] int,

    [DateOfService] varchar(25),

    [Notes] varchar(100),

    [CustomerID] int,

    [PartsUsedID] int,

    PRIMARY KEY ([ServiceTicketID])

);

CREATE INDEX [ServiceTicket_FK] ON [ServiceTicket] ([CustomerID], [PartsUsedID]);

CREATE TABLE [PartsUsed] (

    [PartsUsedID] int,

    [PartID] int,

    [PriceOfPart] int,

    [NumberOfPartsUsed] int,

    [CustomerID] int,

    [ServiceTicketID] int,

    PRIMARY KEY ([PartsUsedID])

);

CREATE INDEX [PartsUsed_FK] ON [PartsUsed] ([CustomerID], [ServiceTicketID]);

Add a comment
Know the answer?
Add Answer to:
This script isn't working with SQL Server 2012, It keeps giving me an error of: There...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. Examine the SQL Script for this test.  Explain the purpose of each of the stored procedures...

    2. Examine the SQL Script for this test.  Explain the purpose of each of the stored procedures listed below.   Test2SP1 Test2SP2 Test2SP3 Test2SP4 Test2SP5 Test2SP6 DATABASE CODE: if db_id('Test2PremierProducts') is not null begin use master alter database Test2PremierProducts set SINGLE_USER with rollback immediate drop database Test2PremierProducts end create database Test2PremierProducts go USE Test2PremierProducts; go /* create the tables */ CREATE TABLE Rep (RepNum int Identity(10,10), LastName VARCHAR(15), FirstName VARCHAR(15), Street VARCHAR(15), City VARCHAR(15), State VARCHAR(2), Zip VARCHAR(5), Commission MONEY, Rate DECIMAL(3,2),...

  • Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins...

    Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins use from clause) Need to Create a Query to display products purchased by customers in Germany that were not purchased by customers in the US. Customers PK Customer D CompanyName Contact Name Contact Title Address City State OrRegion PostalCode Country Phone char(5) varchar(40) varchar(30) varchar(30) varchar(60) varchar(15) varchar(15) varchar(10) varchar(15) varchar(24) varchar(24) Order Details Orders PK OrderID int FK CustomerlD char(5) FK Employeeld int...

  • Given the following table structure, write the SQL code to display all the first and last...

    Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that begins with the letter 'M! CREATE TABLE Persons Personi int LastName varchar(80). FirstName varchar(80). Address varchar(125). State char(2) Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that does not contain the letter 'S: CREATE TABLE Persons PersonlDint,...

  • Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins...

    Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins use from clause) Need to Create a Query because Northwind Traders wants to make sure that all orders are shipped within 10 days. Display any orders that were not shipped within 10 days. Include the OrderID, the OrderDate, and the number of days it took before the order was shipped. Customers PK Customer D CompanyName Contact Name Contact Title Address City State OrRegion PostalCode...

  • im currently working on an sql database homework for a fundamentals class but im not too...

    im currently working on an sql database homework for a fundamentals class but im not too sure if my results are alright and would like to compare results, the assignment is as follows: O4pk,fk evaluate de data models, the specifications and table contents: equipment_tb Assigned_Equipment_tb workers_tb pk serial_number int pk,fk serial number int pk worker_id int, Surrogate brand char(10) worker id int Lastname char(100) model char(15) assigned_date date Firstname char(50) processor char(15) department int processor_velocity number (3,2) email char(200) memory...

  • Chapter 2 How to use the Management Studio Before you start the exercises... Before you start...

    Chapter 2 How to use the Management Studio Before you start the exercises... Before you start these exercises, you need to install SQL Server and the SQL Server Management Studio. The procedures for doing both of these tasks are provided in appendix A of the book. In addition, you'll need to get the Exercise Starts directory from your instructor. This directory contains some script files that you need to do these exercises. Exercises In these exercises, you'll use SQL Server...

  • Write an SQL query to return the users who posted the most number of jokes on...

    Write an SQL query to return the users who posted the most number of jokes on 1/1/2019. Database: create table User( userid varchar(30) not null, password varchar(30), firstname varchar(30), lastname varchar(50), email varchar(50), gender char(1), age integer, banned boolean, primary key(userid), unique(email)); create table MyFriends( userid varchar(30), friendid varchar(30), primary key(userid,friendid), foreign key(userid) references User, foreign key(friendid) references User(userid)); Create table Jokes( Jokeid integer, title varchar(100), description varchar(255), authorid varchar(30) not null, primary key(jokeid), posttime Datetime, foreign key(authorid) references User(userid));...

  • Define an SQL view JokesNum that gives the number of jokes each user posts on each...

    Define an SQL view JokesNum that gives the number of jokes each user posts on each day. Database: create table User( userid varchar(30) not null, password varchar(30), firstname varchar(30), lastname varchar(50), email varchar(50), gender char(1), age integer, banned boolean, primary key(userid), unique(email)); create table MyFriends( userid varchar(30), friendid varchar(30), primary key(userid,friendid), foreign key(userid) references User, foreign key(friendid) references User(userid)); Create table Jokes( Jokeid integer, title varchar(100), description varchar(255), authorid varchar(30) not null, primary key(jokeid), posttime Datetime, foreign key(authorid) references User(userid));...

  • [IN SQL] New to working in SQL and I need to make a database called HAFH....

    [IN SQL] New to working in SQL and I need to make a database called HAFH. I am trying to create tables for the database with the information from the photo above but having issues. I am looking for the syntax that successfully creates these tables, and references each other. I know each table has to be made in a specific order, and that is what I am struggling with. INSPECTOR InsID InsName INSPECTING InsID (FK) BuildingID (FK) Date Last...

  • Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins...

    Question for SQL in MS SQL Server Management Studio (Please don't use where clause for Joins use from clause) Need to Create a Query because Northwind Traders has decided to increase their retail prices. Write a query that shows the product name, the current price, and the new price. Make sure the new price is listed to 2 decimal points. Follow below guidelines on new retail price: a.         If the category is beverages or dairy products, increase the price by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT