Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. can not get union recordset from two Sql Server2K store procedure

can not get union recordset from two Sql Server2K store procedure

Scheduled Pinned Locked Moved Database
databasecomsysadminbusinesshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zhenjie Fu
    wrote on last edited by
    #1

    There are two store procedure on same DB server: create procedure usp_A as declare @ShiftName as datetime select @ShiftName=getdate() select * from LineConfig where Cur_PlanQty_0=0 GO create procedure usp_B as select * from LineConfig where Cur_PlanQty_0=1 GO I use follow sql want to get the union record sets select * from openrowset('sqloledb','trusted_connection=yes','abc.dbo.usp_A') U N I O N ALL select * from openrowset('sqloledb','trusted_connection=yes','abc.dbo.usp_B') get the follow error message: Could not execute query against OLE DB provider 'sqloledb'. The provider could not support a required property. The provider indicates that conflicts occurred with other properties or requirements. OLE/DB provider returned message: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. if I remove the usp_A the local variable operation sentence: select @ShiftName=getdate() the error message disappear. if I add new sentence such as: declare @ShiftValue as varchar(10) the same error message display again.

    L 1 Reply Last reply
    0
    • Z Zhenjie Fu

      There are two store procedure on same DB server: create procedure usp_A as declare @ShiftName as datetime select @ShiftName=getdate() select * from LineConfig where Cur_PlanQty_0=0 GO create procedure usp_B as select * from LineConfig where Cur_PlanQty_0=1 GO I use follow sql want to get the union record sets select * from openrowset('sqloledb','trusted_connection=yes','abc.dbo.usp_A') U N I O N ALL select * from openrowset('sqloledb','trusted_connection=yes','abc.dbo.usp_B') get the follow error message: Could not execute query against OLE DB provider 'sqloledb'. The provider could not support a required property. The provider indicates that conflicts occurred with other properties or requirements. OLE/DB provider returned message: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. if I remove the usp_A the local variable operation sentence: select @ShiftName=getdate() the error message disappear. if I add new sentence such as: declare @ShiftValue as varchar(10) the same error message display again.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Don't UNION on an OpenRowSet. Import it into a local (temp) table, and union from there. That way you'll also see which of both procedures is failing.

      Bastard Programmer from Hell :suss:

      Z 1 Reply Last reply
      0
      • L Lost User

        Don't UNION on an OpenRowSet. Import it into a local (temp) table, and union from there. That way you'll also see which of both procedures is failing.

        Bastard Programmer from Hell :suss:

        Z Offline
        Z Offline
        Zhenjie Fu
        wrote on last edited by
        #3

        I have to insert the temp record into a temp table in order to resolve the issue at last. But I think I have a lot of user store procedures to compute record sets. Do I have to create a lot of temp tables? Is it a bug or some mis-understand by me?

        L 1 Reply Last reply
        0
        • Z Zhenjie Fu

          I have to insert the temp record into a temp table in order to resolve the issue at last. But I think I have a lot of user store procedures to compute record sets. Do I have to create a lot of temp tables? Is it a bug or some mis-understand by me?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Zhenjie Fu wrote:

          Do I have to create a lot of temp tables?

          Nope, only for the two tables that you're importing with the OpenRowSet-command.

          Zhenjie Fu wrote:

          Is it a bug or some mis-understand by me?

          It's an error in one of the imports. Hence the suggestion to select those two first into a temporary table, and then to union on those.

          Bastard Programmer from Hell :suss:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups