I figured out how to pass a value to an openquery statement but now the problem I have is getting the results of the statment. I decalred the @TSql but then when i try to print the @Req it gets nothing, no value, when I print the @TSql it print the whole sql statement. how do I get the value from this. I have many statments that are part of an Sp that does calcualtions I need to get the @Req and @Asgn but it does not seemt o get them.
Select @TSql = 'Select @Req = AUTH From OPENQUERY(SIDPERS, ''Select SUM(AUTH) AUTH from MNLOCAL_ACN_AUTH where UPC = ''''' + @Unit + ''''''')'
Select @TSql = 'Select @Asgn = ASGN From OPENQUERY(SIDPERS, ''Select SUM(COUNT_SSN) ASGN from MNLOCAL_ACN_ASGN a INNER JOIN MNLOCAL_ACN_AUTH aa on aa.upc = a.upc and aa.para = a.para and aa.line = a.line where aa.OS IS NULL AND a.UPC = ''''' + @Unit + ''''''')'