For my it's ok this solution but I recive a error message
declare @ConditionField nvarchar(50), @ConditionValue nvarchar(50), @InvolvedTable nvarchar(50), @CondValue nvarchar(50) set @ConditionField = 'MaterialID' set @CondValue = '3' set @InvolvedTable = 'EAFAdditions' if exists (select @ConditionField, @ConditionValue from @InvolvedTable where @CondValue = 3) begin print 'ciaio' end
He said me i must declare variable @InvolvedTable on from clausule; why?????
you can't use a variable in the FROM clause like this. You need to use dynamic sql if you want to pass an argument to your sproc (a table name for example) that is then used in a the FROM clause of a query.