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
 Creating Tables for a certain database

Author  Topic 

PoisonousFish
Starting Member

1 Post

Posted - 2009-05-09 : 16:47:27
Okay in SQL express, I have created a database called AccessBooks. I know how to create tables graphically for this database, but I would rather use queries. For instance, how do I apply the following query to the database I created? Thanks for your time.

create table names (
personID int PRIMARY KEY IDENTITY,
firstName varchar (30) NOT NULL,
lastName varchar (30) NOT NULL
PRIMARY KEY (personID)
)

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-05-09 : 22:27:05
Did you look at Booksonline?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-10 : 02:19:02
what happened when you executed above statement in a query window connecting to your db?
Go to Top of Page

kfluffie
Posting Yak Master

103 Posts

Posted - 2009-05-10 : 08:27:13
quote:
Originally posted by PoisonousFish

Okay in SQL express, I have created a database called AccessBooks. I know how to create tables graphically for this database, but I would rather use queries. For instance, how do I apply the following query to the database I created? Thanks for your time.

create table names (
personID int PRIMARY KEY IDENTITY,
firstName varchar (30) NOT NULL,
lastName varchar (30) NOT NULL
PRIMARY KEY (personID)
)




Hi!
When I process your query I recieves this error message:
Msg 8110, Level 16, State 0, Line 1
Cannot add multiple PRIMARY KEY constraints to table 'names'.


You having two "Primary Keys" statement towards PersonID.
http://msdn.microsoft.com/en-us/library/aa258255(SQL.80).aspx

Best Regards,
KFluffie
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-10 : 09:29:09
[code]create table names (
personID int PRIMARY KEY IDENTITY,
firstName varchar (30) NOT NULL,
lastName varchar (30) NOT NULL
PRIMARY KEY (personID)
)[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -