+ Reply to Thread
Results 1 to 4 of 4

Use dynamic file for SQL query instead of static code

  1. #1
    Registered User
    Join Date
    09-29-2021
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    2

    Use dynamic file for SQL query instead of static code

    I am using the Power Query to get data directly from a MS SQL Server we use.

    Instead of having to add the code into the window I want it to reference a separate file instead
    Highlighted below is the default syntax used
    Capture1.PNG

    I want to replace the highlighted portion with a file path instead, or something that would achieve the same thing.

    Reason for needing this, the query I use needs to be changed at weekly intervals, and once a query is placed the formatting is a mess and making changes is quite hard

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,910

    Re: Use dynamic file for SQL query instead of static code

    You could build a parameter query and have the variable from that parameter complete the Source.

    Here is a link to help you get started https://www.youtube.com/watch?v=ppM-mLckQfs

    and here is another way

    https://www.howtoexcel.org/power-que...r-power-query/
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    09-29-2021
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    2

    Re: Use dynamic file for SQL query instead of static code

    Thanks for the response

    That works for using files as data sources, like a CSV or something.
    I tried setting this up for a SQL Server connection, syntax and setup looks like it should be working, but doesn't

    An error occurred in the ‘fParameters’ query. Expression.Error: The field 'Value' of the record wasn't found.

    Will keep trying to see if I am missing something

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,910

    Re: Use dynamic file for SQL query instead of static code

    See if this type of parameter works for you.

    https://www.youtube.com/watch?v=gK2yBpiITvI

+ 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. Converting code from static to dynamic
    By ianquiksilver in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-20-2017, 04:38 AM
  2. Replies: 2
    Last Post: 12-28-2015, 08:30 AM
  3. [SOLVED] VBA - Static code to dynamic
    By gan_xl in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-06-2014, 11:51 AM
  4. [SOLVED] Changing code from Static to Dynamic
    By JamesFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2013, 04:33 AM
  5. [SOLVED] Changing static code to dynamic code
    By JamesFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2013, 07:31 AM
  6. [SOLVED] Make Static code Dynamic
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-05-2012, 11:09 AM
  7. Static Web Query Syntax
    By Pak Bob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-26-2008, 02:26 PM

Tags for this Thread

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