I want to run the following SELECT query:
DECLARE @ColumnName nvarchar(50)
SET @ColumnName = 'AlarmID' -- actually these are calculated
-- by another SELECT but this isn't relevant
SELECT MIN(@ColumnName) FROM INSERTED
This doesn't work, it returns the value of @ColumnName instead of the actual data. How can I make this work?
I cannot put the SELECT into a string and run it with sp_executesql because I will lose access to the INSERTED table (this is running in a trigger).