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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-03-13 : 12:35:49
|
Craig writes "I have been tasked with designing a relational database(which I think I have done a pretty good job at) and am now attempting to get my head around the SQL needed to not only insert data into these tables, but to also update it.
Lets take the "Orders" example I see from time to time. There is of course a "Customers" with a PK for each customer. The "Orders" table has a FK field for the "Customer" PK relationship.
Here is the scenerio.
How can I add a NEW customer (which will generate a new "CUSTOMERID" PK) AND add an order for that new customer in the same INSERT statement. An example should be all I need for this, then I can take it from there.
Also,
That same customer calls 2 hours later and wants to make a modification to his order(in the "Orders" table) AND to his address information (in the "Customer" table). What would the UPDATE statement look like for this type of action?
These may sound like simple questions, and I may just be a simpleton, but I have looked and looked but just cannot seem to find plain answers to these types of questions.
To put it in a nutshell, I need to have an example of an INSERT statement which adds new rows to a Table with a PK and then cascade more inserts into the related FK tables.
I hope this request was not too vague and that someone out there will lend a hand. Thanks.
SQLServer Version: 2000 Windows Version: Windows 2000 Adv. Server SP1
Craig" |
|
|
|
|
|