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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Posting Yak Master

151 Posts

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

Flowing Fount of Yak Knowledge

6065 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
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000