Link to home
Start Free TrialLog in
Avatar of HKFuey
HKFueyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Trigger selecting another database

I have a trigger to email me when a field changes in one table. I want it to use an email address from a table in another database, how do I do this?

Variables are these:  @Rep varchar(20),  @Sord varchar(20)

@Sord is taken from the table that is being changed in the current database.

This is the line that does not work: -
                  set @Rep = isnull((Select Salesperson from SERVER.dbName.dbo.Table
                  where SalesOrder = @Sord),'None')

It returns 'None' even though I know the data exists in the other database.

Can anyone help?
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah, that was my next question to you but I'm happy that you solved it out.
Cheers
Avatar of HKFuey

ASKER

Thanks for speedy response!!