• OPENQUERY does not allow variables, only literal/static queries.

    Try code below instead.

    --temporarily add "TOP (100)" to the query for testing purposes

    SET @tsql = STUFF(@tsql, CHARINDEX('SELECT', @tsql) + 6, 0, ' TOP (100) ')

    PRINT @tsql

    EXEC(@tsql) AT [ENIQSQLSERVER]

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.