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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query on data in another table

Author  Topic 

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-03-14 : 08:19:19
query on data in another table.
I have two tables.
Table 1
EventID EventName
01234 Jackpot


Table 2
EventName Amount
Jackpot 123.00
EmptyCanister 14.00

I would like to query Table2 based on the events in
the Table1. How do I do this ?
Not using select * from Table2 where EventName = 'Jackpot'


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-03-14 : 08:28:51
use INNER JOIN

select *
from table1 t1 inner join table2 t2
on t1.EventID = t2.EventName



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-03-17 : 01:56:10
Much appreciated.
One more thing.....
I created an insert trigger on Table2.
If the EventName in Table2 = the EventName in Table1
Then the insert trigger on Table2 must fire & insert on another
database that is a linked server.
The linked server table is exactly the same as Table2
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-17 : 12:55:31
Insert trigger will fire only when you perform insertion on Table2. Check for this condition on insertion of a record to Table2 and if matching then INSERT the record into linked server.
Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-03-19 : 03:42:58
How do I check the condition from Table1 ?
Go to Top of Page
   

- Advertisement -