+ Reply to Thread
Results 1 to 7 of 7

Command text in the Connection Properties of External Data drawn from SQL

  1. #1
    Registered User
    Join Date
    07-11-2016
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    8

    Exclamation Command text in the Connection Properties of External Data drawn from SQL

    Hi,

    I am hoping to alter the way in which I receive my data from SQL database. Currently, I am able to pull data directly from SQL, and this generates several different columns of data that I do not need. For example, I only need columns 1, 4, 7 but I have columns 1 through 8 of data. I am hoping to write some sort of command text in the connection properties to essentially delete these columns in that every time the data is refreshed, these columns will not appear / are not extracted to my excel file.

    Any help would be greatly appreciated.

    Thank you.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Command text in the Connection Properties of External Data drawn from SQL

    Hi,

    Your command would be a SQL query that only selects the columns you require:

    SELECT [fieldname1], [fieldname4], [fieldname7] FROM table_name

    If possible, it would be more efficient to use a view or stored procedure on the SQL server.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    07-11-2016
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    8

    Re: Command text in the Connection Properties of External Data drawn from SQL

    Hi,

    I already have a SQL query that selects the data because it is not directly drawn from sql. Is there any way for me that, after that query, I create a new query that will only take the columns that I require?

    Thanks a lot.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Command text in the Connection Properties of External Data drawn from SQL

    Yes there is - you can use a SELECT query as outlined above.

  5. #5
    Registered User
    Join Date
    07-11-2016
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    8

    Re: Command text in the Connection Properties of External Data drawn from SQL

    I am drawing from multiple tables in sql to generate the file in excel. What table would I use after the "FROM" command?

  6. #6
    Registered User
    Join Date
    07-11-2016
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    8

    Re: Command text in the Connection Properties of External Data drawn from SQL

    My first SQL query uses select function to pull data from multiple tables. How do I create another query to specify which data I want to keep?

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Command text in the Connection Properties of External Data drawn from SQL

    You would use the query name as the table in your SELECT statement.

+ 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. Excel External Data Connection
    By morerockin in forum Excel General
    Replies: 1
    Last Post: 10-13-2015, 09:23 AM
  2. [SOLVED] SQL Data Connection rewriting Command text to pull mutliple names
    By cmorten82 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2015, 02:54 PM
  3. Modify Connection Command Text from Cell Value
    By gedwards913 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-13-2015, 02:49 AM
  4. Excel External Connection Dropping Password from Connection String?
    By mar0isa in forum Access Tables & Databases
    Replies: 1
    Last Post: 03-06-2015, 10:35 AM
  5. Replies: 0
    Last Post: 05-29-2013, 10:28 AM
  6. Replies: 0
    Last Post: 11-16-2011, 03:59 PM
  7. Automatic update of External Connection Text File
    By improveddc in forum Excel General
    Replies: 0
    Last Post: 01-21-2009, 06:36 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