I've got several table with the column Archive
. On a trigger I would like to check if the value exist in several tables.
Of course I can duplicate the query for each table but I think it could be easier to do this with a variable.
I've got a table RefTable
with all the table created in the datase ID, TblName
.
All the table are in the same database
Here is what I would like but it is not working :
IF EXISTS (SELECT archive from (select TblName FROM RefTable) WHERE archive = @var)