+ Reply to Thread
Results 1 to 13 of 13

SQL Stored Procedure (Without Parameters) In Excel

  1. #1
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    SQL Stored Procedure (Without Parameters) In Excel

    Hi,

    I have an SQL Stored Procedure (Without Parameters) for which I want to return data in Excel.

    Currently I am using this link as guidance >

    http://codebyjoshua.blogspot.in/2012...er-stored.html
    http://www.sqlservercentral.com/Foru...54-2799-1.aspx

    However, I am unable to get the data to be returned.

    Below are the necessary details -

    Database Name – ZZ_Common
    SP Name – Update_Vol

    Can anyone help me with this?
    Cheers!
    Deep Dave

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: SQL Stored Procedure (Without Parameters) In Excel

    What code did you try and what happened? It would also be helpful to see the SQL for the SP.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: SQL Stored Procedure (Without Parameters) In Excel

    I tried it using 2 methods -

    1) Using MS Query - I did it everything as per this link - http://codebyjoshua.blogspot.in/2012...er-stored.html

    {CALL ZZ_Common.dbo.Update_Vol} and removed all the (?, ?, ?) as I had no parameters.

    2) I also used FROM SQL SERVER, where on the Connection Strings Dialogue Box I Selected Command Type as SQL and Command Text as EXECUTE Update_Vol

    Stored Proc -

    Please Login or Register  to view this content.
    It returned this error

    Capture.GIF

    However, the DB & its Tables are all working fine..
    Last edited by NeedForExcel; 05-13-2015 at 02:07 AM.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: SQL Stored Procedure (Without Parameters) In Excel

    Which stored proc is that? If it's Update_vol it appears to call itself?

  5. #5
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: SQL Stored Procedure (Without Parameters) In Excel

    I am sorry, I don't use SQL too much.. Here it is -

    Please Login or Register  to view this content.
    Last edited by NeedForExcel; 05-13-2015 at 03:04 AM.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: SQL Stored Procedure (Without Parameters) In Excel

    What is Return Value when you run that in SSMS?

  7. #7
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: SQL Stored Procedure (Without Parameters) In Excel

    The Return Value is Zero!

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: SQL Stored Procedure (Without Parameters) In Excel

    Does the sproc actually execute even though you get an error?

  9. #9
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: SQL Stored Procedure (Without Parameters) In Excel

    Actually when I use the MS Query to get the data, the Store Proc seems to execute as I get a Pop-Up saying the Query Executed Successfully, but surprisingly no data is displayed on the grid.. Using the other way, it does not seem to work..

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: SQL Stored Procedure (Without Parameters) In Excel

    What data are you expecting, the stored procedure returns Zero

  11. #11
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: SQL Stored Procedure (Without Parameters) In Excel

    The Stored Proc Returns a Value Zero.. It isnt returning Null.. I am expecting that Zero to be displayed in MS Query/Excel.

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: SQL Stored Procedure (Without Parameters) In Excel

    You're only seeing Zero in SSMS as you're asking for a return value, if you just execute the stored procedure you won't see anything - it won't have a return value.
    Try using:
    Please Login or Register  to view this content.
    In msquery

  13. #13
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: SQL Stored Procedure (Without Parameters) In Excel

    I am not sure whats really is going wrong as I am very new to SQL..

    All the 3 SPs that I have, Update some Data.. Is that the reason why nothing is being returned?
    Last edited by NeedForExcel; 05-13-2015 at 06:48 AM.

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: SQL Stored Procedure (Without Parameters) In Excel

    It's because the Stored Procedures have no Return value, you need to add one if you want to return something

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-02-2012, 03:06 PM
  2. How do I run an MSSQL 2005 stored procedure with no parameters?
    By Scotbot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2012, 06:46 AM
  3. VBA to Pass Parameters to SQL Stored Procedure
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2011, 01:31 PM
  4. Replies: 2
    Last Post: 06-16-2006, 02:24 PM
  5. External Data from Stored Procedure with parameters
    By Ben Rum in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2005, 12:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1