SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Save the ID automatically
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Exir
Posting Yak Master

151 Posts

Posted - 04/05/2013 :  15:58:43  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6062 Posts

Posted - 04/05/2013 :  17:42:27  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000