• Thanks for the suggestions.

    I have attached the query as attachment name "main query" which takes time.

    Also I modified the query with open query and ran on the server which gave the following error statement upon executing:

    The OLE DB provider "SAOLEDB.11" for linked server "ENIQSQLSERVER" supplied inconsistent metadata. The object "(user generated expression)" was missing the expected column "Bmk1000".

    I have also attached the modified query as "open query".

    Thanks.