Video není dostupné.
Omlouváme se.

Call a SQL Server Stored Procedure using Excel Parameters

Sdílet
Vložit
  • čas přidán 19. 08. 2024
  • Sometimes we need to dynamically transfer data from SQL Server into Excel without the manual cutting and pasting. By the end of this video, you'll know how to use sp_executesql and parameters to pass data between Excel and SQL Server. Unlike the first video where I demonstrated using a raw SQL query, parameterized queries can improve query performance by avoiding the need for the database engine to compile the same query multiple times. Additionally, sp_executesql is more secure, as it helps prevent SQL injection attacks.
    Watch Part 1 for worksheet details and for the quick way to retrieve data: • Passing Parameter Valu...
    ★☆★ Join this channel to get access to perks: ★☆★
    / @anthonysmoak
    #SQL #analytics #tsql #excel #dataanalyst #data
    Download the Database used in the video: learn.microsof...
    ★☆★ FOLLOW ME BELOW: ★☆★
    Blog ► anthonysmoak.com/
    Instagram ► / @anthonysmoakdata
    Facebook ► / anthonybsmoak
    Tableau Public ► bit.ly/3JMKsLY

Komentáře • 23

  • @abdullahquhtani4247
    @abdullahquhtani4247 Před rokem +1

    Thank you very much. 👍🏼

  • @Faisal1504
    @Faisal1504 Před 7 měsíci +1

    Very nice.

  • @oussamakherroub1103
    @oussamakherroub1103 Před rokem

    Thank you for this video it works perfectly, but i have the error 438 when we run this macro in an other PC

  • @mnvsaikiran
    @mnvsaikiran Před 19 dny

    Very nice but the video is fast. Please see if you can make it go slow.

    • @AnthonySmoak
      @AnthonySmoak  Před 19 dny

      Adjust your playback speed in the settings.

  • @justuju
    @justuju Před 9 měsíci +1

    Hey Anthony nice video. What do I need to do if instead of details I want to do pivot table representation? meaning I want to do all this, but then data needs to be transformed to a pivot table without user interaction.

    • @AnthonySmoak
      @AnthonySmoak  Před 9 měsíci +2

      Thanks. You can repeat the process on a table that has been "pre-pivoted" in SQL Server or most likely you will need some sort of VBA code to automate the pivot. Play around with the macro recorder and observe what code it develops when you create a pivot table.

  • @devendrateluguchannel
    @devendrateluguchannel Před rokem +1

    how to create stored procedure please give me a video step by step .....

    • @AnthonySmoak
      @AnthonySmoak  Před rokem

      I literally show the stored procedure code I use in the video. 😊

  • @jaygibbs7218
    @jaygibbs7218 Před 20 dny

    I cant get my button to execute I click it and nothing I tried this 3 times and I dont see anything wrong

    • @AnthonySmoak
      @AnthonySmoak  Před 20 dny

      @@jaygibbs7218 I assume you have design mode turned off and your code is placed in the on click action?

  • @HerbertWoelffer
    @HerbertWoelffer Před rokem

    Followed everything. Runs great on mine but some other users get runtime error 1004 on the refresh line of the macro. Thoughts?

    • @AnthonySmoak
      @AnthonySmoak  Před rokem

      Double check the cell references.

    • @terryzimmerman8795
      @terryzimmerman8795 Před 11 měsíci

      I spent 2 days trying to resolve this issue. It is a common issue people have and I'm not sure why. To fix, just replace the refresh line with: ActiveWorkbook.RefreshAll

    • @NyphronRising
      @NyphronRising Před 11 měsíci

      i find its because the Refresh method isnt available to me for some reason

  • @emmanuel.aggrey
    @emmanuel.aggrey Před rokem

    thanks for the video, please can share this file with us so we can edit it according to our need or share the code you pasted. I will be much greafull thank you sir

  • @jdwyer4851
    @jdwyer4851 Před 2 měsíci

    how is this in anyway better than MSQuery where i could just do {Call MyStoredProcedure(?,?,?)}. Not a bit of VBA or a macro, i could just assign the 3 parameters to cells on the sheet.

    • @AnthonySmoak
      @AnthonySmoak  Před 2 měsíci

      I know MSQuery is listed as an older legacy option and you have to manually enable it in the latest version of Office 365 Excel (will it continue to be supported like VBA)? However, you have given me an option to test, I'll let you know how it goes.

    • @jdwyer4851
      @jdwyer4851 Před 2 měsíci

      @@AnthonySmoak My complaint is really with Microsoft. They took something simple and replaced it with a nightmare. I'm a programmer so other than disliking VBA, i have no problem with this approach other than it used to be very simple with MSQuery.

    • @AnthonySmoak
      @AnthonySmoak  Před měsícem +1

      @@jdwyer4851 I made a video exploring the MS Query approach. Thanks for the comment. czcams.com/video/2oT-PhgcKa8/video.htmlfeature=shared

    • @jdwyer4851
      @jdwyer4851 Před měsícem

      @@AnthonySmoak Thank you for doing that. Microsoft has buried MSQuery on the current Excel version and you have to add it to the menu yourself. I hope that it doesn't go away completely, or at least if it does Microsoft could replace it something that its as equally simple. I'm a programmer, but for fast ad-hoc solutions I can turnout an Excel doc calling a stored procedure in minutes. Perhaps the more people who know about and use MSQuery the less likely it gets killed by Microsoft.