SQL Trigger selecting another database
Posted on 2016-09-27
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?