I have created a SQL query that will return rows from an Oracle linked server. The query works fine and will return 40 rows, for example. I would like the results to only be inserted into a table if the number of rows returned is greater than 40.
My thinking would then be that I could create a trigger to fire out an email to say the number has been breached.
DECLARE @cnt INT
SELECT @cnt = COUNT(*) FROM LinkedServer.database.schemaname.tablename
IF @cnt > 40
INSERT INTO table1 VALUES(col1, col2, col3 .....)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With