Re: MS Query - From in SQL

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



In addition to updating the Connection property to update the DB command
string, in order to change the FROM clause in the SQL you will need to modify
the CommandText property, which should contain the SQL query. You could use
the Replace function to modify it, e.g.
Replace(Sheets("MySheet").QueryTables(1).CommandText, "FROM AAA", "FROM BBB")

"Robert Bruce" wrote:

> mtate wrote:
> > Question...
> > We have quite a few queries developed in Excel/MS Query that query an
> > AS400. We need to share these with users at other locations that use
> > an AS400 with a different name. Is there any way around changing the
> > SQL FROM statement for the AS400 machine name to another AS400
> > machine name without editing the query in MS Query and doing it in
> > View, SQL? Looking for the quick, easy way to do this, because there
> > are too many to change this way.
>
> If you used MSQuery to return the results then you will have a QueryTable
> object on your worksheet. As long as you chose to save the query definition
> with the sheet, the QueryTable object will have a Connection property that
> corresponds to the connectionstring used by the query. Your mission, I
> suppose, is to ensure that this property is updated with the appropriate
> value depending on who opens the workbook. You could put a lookup table of
> usernames and connectionstrings on a hidden sheet.
>
> Rob
>
>
>
.



Relevant Pages

  • Re: What commands can a user execute
    ... simple security query rather than BOL. ... example would be the command UPDATE STATISTICS. ... ALTER permissions on the table or view. ... you could retrieve this with a query from SQL Server rather than Books ...
    (microsoft.public.sqlserver.security)
  • help
    ... You can do this with an Access update query object or ... attach the SQL to the form through AccessVB. ... you create your query and then add a button to the form ... string that has your SQL command and use the command ...
    (microsoft.public.access.forms)
  • Re: Timeout Expired (0x80040E31)
    ... case provider will wait until SQL statement finishes completely. ... > I have an ASP page that runs a simple INSERT query. ... > [ODBC SQL Server Driver]Timeout expired ... It started when the page was using an "AddNew" command to ...
    (microsoft.public.vb.database.ado)
  • Syntax Error in queryout
    ... I'm trying to run the following command in the master db from SQL the Query ... Analyzer and get a "Syntax Error in 'queryout'" message: ...
    (microsoft.public.sqlserver.programming)
  • Re: How do I issue SQL to a Access database from command line
    ... In Access go to the Query Tab. ... SQL View. ... Just remember to end you command with a semicolon ";". ... Access database that can execute the query and return the results. ...
    (microsoft.public.access.externaldata)