Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Msg 102, Level 15, State 1, Line 59

Author  Topic 

Juan Rodriguez
Starting Member

1 Post

Posted - 2009-08-11 : 13:49:09

Please help, I am totally new to SQL. Thanks

CREATE TABLE SOFTWAREOBJECTS(
PublicationTitle VARCHAR(40) NOTNULL,
ISBN VARCHAR(10) NOT NULL,
TrackingNumber INT NOT NULL,
Price INT NOT NULL,
Rating INT NULL,
Website VARCHAR(40) NOT NULL UNIQUE,
CONSTRAINT SOFTWAREOBJECTS_PK PRIMARY KEY

PublicationTitle),
CONSTRAINT AUTHOR_FK FOREIGN KEY(AuthorID)
REFERENCES AUTHOR(AuthorId)
ON UPDATE CASCADE
);


CREATE TABLE EMPLOYEE(
EmployeeID VARCHAR(10) NOT NULL,
LastName CHAR(20) NOT NULL,
FirstName CHAR(20) NOT NULL,
Address VARCHAR(40) NULL,
CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EmployeeID)
);


CREATE TABLE AUTHOR(
AuthorID VARCHAR(10) NOT NULL,
LastName CHAR(20) NOT NULL,
FirstName CHAR(20) NOT NULL,
Address VARCHAR(40) NOT NULL,
RoyaltyPayments INT NOT NULL,
NumberBooksSold INT NOT NULL,
CONSTRAINT AUTHOR_PK PRIMARY KEY(AuthorID)
);


CREATE TABLE CUSTOMER(
CustomerID VARCHAR(10) NOT NULL,
LastName CHAR(20) NOT NULL,
FirstName CHAR(20) NOT NULL,
Address VARCHAR(40) NOT NULL,
PhoneNumber CHAR(12) NOT NULL,
Email VARCHAR(40) NOT NULL,UNIQUE,
CONSTRAINT CUSTOMER_PK PRIMARY KEY(CustomerID)
);


CREATE TABLE SALESORDER(
SalesTrackingNO VARCHAR(10) NOT NULL,
Date DATETIME NOT NULL,
Quantity INT NOT NULL,
BillToAddress VARCHAR(40) NOT NULL,
CreditCard CHAR(20) NOT NULL,
ExpDate DATETIME NOT NULL,
Tax INT NOT NULL,
PromoCode VARCHAR(10) NULL,
SubTotal INT NOT NULL,
Total INT NOT NULL,
CONSTRAINT SALESORDER_PK PRIMARYKEY

SalesTrackingNO),
CONSTRAINT EMPLOYEE_FK FOREIGN KEY(EmployeeID),
CONSTRAINT CUSTOMER_FK FOREIGN KEY(CustomerID),
CONSTRAINT SOFTWAREOBJECTS_FK PRIMARY KEY(PublicationTitle),
REFERENCES SOFTWAREOBJECTS(PublicationTitle)
ON UPDATE CASCADE

);

Juan Rodriguez

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-11 : 13:53:37
Take a look at the text of your error message. It is telling you exactly what the problem is. Incorrect syntax near 'NOTNULL'

That should be two seperate words: NOT NULL.

There will be other problems as well. Just start with the script for one table get that right before moving on to the next.

EDIT:
WOW! This is a real mess. You have constraints called <something>_FK which you specifiy as a Primary Key.
You have foreign keys set up for columns that don't exist
you have foreign keys that don't reference anything and you have primary keys that do reference other table(col) as if it was a foreign key. ugh.

Try again (and this time pay attention don't just furiously cut and paste) and if you get stuck we'll help you.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -