Click here to Skip to main content
15,895,656 members
Home / Discussions / Database
   

Database

 
GeneralRe: Record is killed after UPDATE Pin
realmontanakid29-Nov-04 20:43
realmontanakid29-Nov-04 20:43 
GeneralCopy rows from one table from another Pin
Luis Alonso Ramos29-Nov-04 9:23
Luis Alonso Ramos29-Nov-04 9:23 
GeneralRe: Copy rows from one table from another Pin
Edbert P29-Nov-04 10:56
Edbert P29-Nov-04 10:56 
GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos29-Nov-04 11:22
Luis Alonso Ramos29-Nov-04 11:22 
GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos30-Nov-04 8:14
Luis Alonso Ramos30-Nov-04 8:14 
GeneralRe: Copy rows from one table from another Pin
Edbert P30-Nov-04 10:49
Edbert P30-Nov-04 10:49 
GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos30-Nov-04 13:25
Luis Alonso Ramos30-Nov-04 13:25 
GeneralRe: Copy rows from one table from another Pin
Edbert P30-Nov-04 15:11
Edbert P30-Nov-04 15:11 
Let's see.
You can already:
1. Insert into Orders.
By this it means you copy record in quotes to orders and give it a new PK (ID_order).
2. Get the ID_order (by using SELECT @@IDENTITY)

According to you,
QuoteItems has :
1. ID_item (PK)
2. ID_quote
3. Description

If you have ID_quote field in the Orders table the sp may look like this:
CREATE PROCEDURE dbo.sp_InsertOrdersItems @ID_quote int  AS

INSERT INTO OrdersItems
(ID_order, Description, Produced)
(
SELECT Orders.ID_order, QuoteItems.Description, false
FROM Orders 
INNER JOIN QuoteItems ON Orders.ID_quote = QuoteItems.ID_Quote
WHERE Orders.ID_Quote = @ID_quote
)

If you don't have ID_quote field in the Orders table then you need to pass ID_order into the sp's parameters.

Hope that helps!

Edbert P.
Sydney, Australia.
GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos30-Nov-04 15:23
Luis Alonso Ramos30-Nov-04 15:23 
GeneralSQL statement help Pin
ruifernandes2429-Nov-04 7:29
ruifernandes2429-Nov-04 7:29 
GeneralRe: SQL statement help Pin
Gerald Schwab29-Nov-04 7:58
Gerald Schwab29-Nov-04 7:58 
GeneralDataSet 2 Xml - element order problem Pin
Xabatcha29-Nov-04 3:18
Xabatcha29-Nov-04 3:18 
QuestionOREIGN KEY REFERENCES? Pin
HahnTech28-Nov-04 12:42
HahnTech28-Nov-04 12:42 
AnswerRe: OREIGN KEY REFERENCES? Pin
Christian Graus28-Nov-04 13:46
protectorChristian Graus28-Nov-04 13:46 
GeneralRe: OREIGN KEY REFERENCES? Pin
HahnTech28-Nov-04 14:54
HahnTech28-Nov-04 14:54 
GeneralRe: OREIGN KEY REFERENCES? Pin
Christian Graus28-Nov-04 18:13
protectorChristian Graus28-Nov-04 18:13 
GeneralRe: OREIGN KEY REFERENCES? Pin
Edbert P28-Nov-04 18:44
Edbert P28-Nov-04 18:44 
GeneralRe: OREIGN KEY REFERENCES? Pin
HahnTech28-Nov-04 23:23
HahnTech28-Nov-04 23:23 
AnswerRe: OREIGN KEY REFERENCES? Pin
Mike Dimmick29-Nov-04 1:00
Mike Dimmick29-Nov-04 1:00 
GeneralRe: OREIGN KEY REFERENCES? Pin
HahnTech29-Nov-04 12:00
HahnTech29-Nov-04 12:00 
AnswerRe: OREIGN KEY REFERENCES? Pin
Chris Meech29-Nov-04 7:16
Chris Meech29-Nov-04 7:16 
GeneralUpdate Statement Pin
jlawren728-Nov-04 12:28
jlawren728-Nov-04 12:28 
GeneralRe: Update Statement Pin
Christian Graus28-Nov-04 13:48
protectorChristian Graus28-Nov-04 13:48 
GeneralRe: Update Statement Pin
Edbert P28-Nov-04 18:39
Edbert P28-Nov-04 18:39 
GeneralRe: Update Statement Pin
jlawren729-Nov-04 1:39
jlawren729-Nov-04 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.