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 2008 Forums
 Transact-SQL (2008)
 Save the ID automatically

Author  Topic 

Exir
Posting Yak Master

151 Posts

Posted - 2013-04-05 : 15:58:43
HI
I want to design a database which saves invoices , each invoice have
some rows of objects and the number of rows are indeterminate

the problem is the ID for each invoices. is it possible in sql to save ID for invoices automatically
or i should insert manually ?


example :

invoiceID - ObjectID - objectName
1- 1 - apple
1- 2 -orange
1- 3 - banana

2- 1 - bag
2- 2 - shoe
2- 3 - trousers
2- 4 - skirt
2- 5 - glasses

3- 1 - bicycle

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-04-05 : 17:42:27
I think you should have two tables:
invoice - PK is (InvoiceID)
Lineitem - PK is (Invoiceid, ObjectID)

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -