Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert data

Status
Not open for further replies.

macca18

Programmer
Joined
Mar 1, 2005
Messages
3
Location
GB
Hi,

I have a table, Alert, that is made up of three entries as shown belowwhich
come from other tables.

Table Alert
-------------
RoomID - (int)PK. This a foreign key from room table
EventTypeID - (int)PK. This is foreighn key from EventType table
RegionID - (int)PK. THis is foreign key from Region table


Table EventType
-------------------
EventTypeID - (int) PK
EventDescription - (nVarChar)


Table Room
--------------
RoomID -(int) PK
Dimensions - (nchar)
.
.

Table Region
---------------
RegionID - (int) PK
RegionDescription -(nvarchar)


I am relatively new to database programming and i am having trouble building
the query to input an entry into the Alert table. I am having trouble because
the entries are ID values from other tables.

What information do I need to be able to add entries to the Alert table?
How do I construct the query?

Thanks In advance
Macca
 
How do you determine which RoomID, EventTypeID, and RegionID belong with each other? There isn't anything in each table that links them together.

-SQLBill

Posting advice: FAQ481-4875
 
In order to add it, you need to have the ID from the related table. You need to either have your inserting logic include the information as a parameter or set up a series of queries to get the information from the related tables prior to inserting.

If I had to guess, you have some type of a procedure that checks remote devices and fires off an "alert" function when certain parameters are met. You could add the logic to your alert function to query the EventType Table and then set up a SP which receives parameters of the 3 related ID's
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top