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
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 primary key + foriegn key

Author  Topic 

ddon07
Starting Member

2 Posts

Posted - 2007-11-12 : 07:27:34
help needed,

sorry for such a basic querry please help me.

i have created 2 tables
both of them has different primary keys
now in first table there is also a refernece for primary key of second table

1) how do i make these both primary keys autoincrement
2) how do i make refernce to primary key of second table

like
table1
itemid itemrate itemcode itemdesscriotion

table2
productid itemid purchaseinvoice invoice amount

also kindly direct me to some quick and easy tutorials on SQL


thanks all for your help.


harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-12 : 07:39:38
1. To make any int column auto-increment, you need to add IDENTITY clause after it.

col1 int identity(1,1)

2. Search SQL Server help for CREATE TABLE keyword. you will get quite good example on how to do it.

3. Google it. you will get plenty of sites for learning sql.
For e.g. http://www.w3schools.com/sql/default.asp

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -