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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. executing procedure via ODBC Connection

executing procedure via ODBC Connection

Scheduled Pinned Locked Moved Database
databasesysadmin
6 Posts 4 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.
  • A Offline
    A Offline
    apoorva_raje
    wrote on last edited by
    #1

    trying to execute this stored procedure using a prg that connects to the server using an ODBC DSN. it doesnot retrieve the result set. CREATE PROCEDURE PROC_1 AS CREATE TABLE #abc ( ssn char(30) ) insert into #abc(ssn) select phone from tbl_users select * from #abc GO when executed directly, ie. say, Query Analyser or Excel, there r no probs encountered. also, when i remove the create n insert stmts, n change the #abc to a table abc, am getting the results. Thanks..

    C A A 3 Replies Last reply
    0
    • A apoorva_raje

      trying to execute this stored procedure using a prg that connects to the server using an ODBC DSN. it doesnot retrieve the result set. CREATE PROCEDURE PROC_1 AS CREATE TABLE #abc ( ssn char(30) ) insert into #abc(ssn) select phone from tbl_users select * from #abc GO when executed directly, ie. say, Query Analyser or Excel, there r no probs encountered. also, when i remove the create n insert stmts, n change the #abc to a table abc, am getting the results. Thanks..

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      A slightly off topic question - but why are you creating a temprorary table, populating it with a fairly simple query then retrieving the result set. Would it not be quicker just to retrieve the result set from the SELECT used on the INSERT? The temp table will just disappear at the end of the stored procedure call, so what use is it? Or is there more code you are not telling us about which may help us answer your query. In other words why are you not just doing:

      SELECT phone from tbl_users


      Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

      A 1 Reply Last reply
      0
      • C Colin Angus Mackay

        A slightly off topic question - but why are you creating a temprorary table, populating it with a fairly simple query then retrieving the result set. Would it not be quicker just to retrieve the result set from the SELECT used on the INSERT? The temp table will just disappear at the end of the stored procedure call, so what use is it? Or is there more code you are not telling us about which may help us answer your query. In other words why are you not just doing:

        SELECT phone from tbl_users


        Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

        A Offline
        A Offline
        apoorva_raje
        wrote on last edited by
        #3

        yeah.. there r more operations that r to be performed on this temp table.. modifications, etc.. but i got to get this running b4 i put in the other stmts... SOS!!

        1 Reply Last reply
        0
        • A apoorva_raje

          trying to execute this stored procedure using a prg that connects to the server using an ODBC DSN. it doesnot retrieve the result set. CREATE PROCEDURE PROC_1 AS CREATE TABLE #abc ( ssn char(30) ) insert into #abc(ssn) select phone from tbl_users select * from #abc GO when executed directly, ie. say, Query Analyser or Excel, there r no probs encountered. also, when i remove the create n insert stmts, n change the #abc to a table abc, am getting the results. Thanks..

          A Offline
          A Offline
          ash04
          wrote on last edited by
          #4

          use this insert into #abc(ssn) select isnull(phone,'') from tbl_users

          DAsh04

          1 Reply Last reply
          0
          • A apoorva_raje

            trying to execute this stored procedure using a prg that connects to the server using an ODBC DSN. it doesnot retrieve the result set. CREATE PROCEDURE PROC_1 AS CREATE TABLE #abc ( ssn char(30) ) insert into #abc(ssn) select phone from tbl_users select * from #abc GO when executed directly, ie. say, Query Analyser or Excel, there r no probs encountered. also, when i remove the create n insert stmts, n change the #abc to a table abc, am getting the results. Thanks..

            A Offline
            A Offline
            andyharman
            wrote on last edited by
            #5

            Try adding

            set nocount on
            

            as the first line of your procedure. This stops SQL-Server from sending-back a running commentary of what its up to (which is probably being counted as the resultset for you current procedure).

            A 1 Reply Last reply
            0
            • A andyharman

              Try adding

              set nocount on
              

              as the first line of your procedure. This stops SQL-Server from sending-back a running commentary of what its up to (which is probably being counted as the resultset for you current procedure).

              A Offline
              A Offline
              apoorva_raje
              wrote on last edited by
              #6

              thx a lot!! kudos..

              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