3 Replies Latest reply on Feb 2, 2016 12:32 PM by Rashmi

    SQL query not displaying the proper output on management studio window via Linked server

    Rashmi

      Hi,

       

      The following sql query gives me the out put without the proper column names:

       

      SELECT * FROM OPENQUERY([PIAF_DEMO],'

      SELECT eh.Name, i.Value

      FROM [HYREF].[Asset].[ElementHierarchy] eh

      INNER JOIN [HYREF].[Asset].

      [ElementAttribute] ea ON ea.ElementID = eh.ElementID,

      [HYREF].[Data].[Archive] i

      WHERE eh.Name = ''F4402''

      AND i.ElementAttributeID = ea.ID

      OPTION (FORCE ORDER, EMBED ERRORS)')

       

      output:

       

      NameValue

      F4402   124

      F4402   Clyde

      F4402   F4402

       

      I want the values to be populated as :

       

      NameValue

      outpower   124

      farmname   Clyde

      farmcode   F4402

       

      Any suggestion please? can this be handled by a single sql query or do I have to define additional variable to identify outpower,farmname and farmcode values? I'm running this query on SQl server management studio by using a linked server .

       

      PS: outpower,framnme and farmcode have been defined on PI AF system explorer.