cismajor97
Weaksauce
- Joined
- Mar 23, 2006
- Messages
- 88
Hello,
I'm trying to figure out how in MS SQL 2005 Express one is able to insert data into multiple tables at once. Here are my tables:
Contact
----------------------
ContactID, int, not null
FirstName, nvarchar(50), not null
LastName, nvarchar(50), not null
AddressID, int, not null
HomePhone, nchar(14), not null
HomeEmail, nvarchar(100), not null
WorkPhone, nchar(14), not null
WorkPhoneExtension, nvarchar(50), not null
WorkEmail, nvarchar(100), not null
Address
------------------------
AddressID, int, not null
Address, nvarchar(50), not null
City, nvarchar(50), not null
StateID, int, not null
ZipCode, nvarchar(50), not null
State
---------------------------
StateID, int, not null
StateName, nvarchar(13), not null
Now the State table will be already filled out since the name of US States won't change. How do I enter the contact address in the Contact table when both tables are being referenced? I think that logically you first enter data in to the address table, and then some how return the ID that was just entered and then use that ID number and enter into the Contact table. Am I on the right track?
I'm trying to figure out how in MS SQL 2005 Express one is able to insert data into multiple tables at once. Here are my tables:
Contact
----------------------
ContactID, int, not null
FirstName, nvarchar(50), not null
LastName, nvarchar(50), not null
AddressID, int, not null
HomePhone, nchar(14), not null
HomeEmail, nvarchar(100), not null
WorkPhone, nchar(14), not null
WorkPhoneExtension, nvarchar(50), not null
WorkEmail, nvarchar(100), not null
Address
------------------------
AddressID, int, not null
Address, nvarchar(50), not null
City, nvarchar(50), not null
StateID, int, not null
ZipCode, nvarchar(50), not null
State
---------------------------
StateID, int, not null
StateName, nvarchar(13), not null
Now the State table will be already filled out since the name of US States won't change. How do I enter the contact address in the Contact table when both tables are being referenced? I think that logically you first enter data in to the address table, and then some how return the ID that was just entered and then use that ID number and enter into the Contact table. Am I on the right track?