By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,699 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,699 IT Pros & Developers. It's quick & easy.

Changing Query Reference Table Names without rebuilding query

P: n/a
Hi:

I have developed a series of complex queries against a table named "timesheetsnew". These
queries work fine. I now wish to apply exactly the same queries to an identically
formatted table called "TimesheetsMaster". Being a neophyte I though I could just copy the
queries, change the name of the table they refer to, and be off and running with a new set
of queries. I have found this does not work!

Does any one know of an easy way to change the name of the table that a query refers to
(the format and contents are the same), without rebuilding the query from scratch?

Thanks

John Baker
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
1. Open the query in SQL View (view menu).
2. Copy the query statement to notepad or Word.
3. Use the search'n'replace function to replace the table name.
4. Paste the result back into SQL View of the query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"John Baker" <Ba******@Verizon.net> wrote in message
news:co********************************@4ax.com...

I have developed a series of complex queries against a table named "timesheetsnew". These queries work fine. I now wish to apply exactly the same queries to an identically formatted table called "TimesheetsMaster". Being a neophyte I though I could just copy the queries, change the name of the table they refer to, and be off and running with a new set of queries. I have found this does not work!

Does any one know of an easy way to change the name of the table that a query refers to (the format and contents are the same), without rebuilding the query from

scratch?
Nov 12 '05 #2

P: n/a
Thank you. That saved me considerable work (and the potential for massive messups).

Thanks again

John Baker

"Allen Browne" <Al*********@SeeSig.Invalid> wrote:
1. Open the query in SQL View (view menu).
2. Copy the query statement to notepad or Word.
3. Use the search'n'replace function to replace the table name.
4. Paste the result back into SQL View of the query.


Nov 12 '05 #3

P: n/a
John Baker wrote:
Thank you. That saved me considerable work (and the potential for massive messups).

Thanks again

John Baker

"Allen Browne" <Al*********@SeeSig.Invalid> wrote:

1. Open the query in SQL View (view menu).
2. Copy the query statement to notepad or Word.
3. Use the search'n'replace function to replace the table name.
4. Paste the result back into SQL View of the query.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Another way is to give the table names aliases. Then, in SQL View,
just change one name - the table name in the FROM clause. E.g.:

SELECT J.OrderDate, F.LastName, O.OrderID
FROM (qryJulianOrders As J INNER JOIN FamilyNames As F On J.CustomerID
= F.CustomerID) INNER JOIN qryLast6MonthsOrders As O ON J.CustomerID =
O.CustomerID

If you wanted to change the names of the tables/queries:

FROM (Julian_Customers As J INNER JOIN LastFamilies As F On
J.CustomerID = F.CustomerID) INNER JOIN qryLastYearOrders As O ON
J.CustomerID = O.CustomerID

All that has to be changed is the FROM clause - the rest of the query
remains the same 'cuz the table alias refers to the changed tables.

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP+t7zIechKqOuFEgEQLxhwCg81/G1os58LWAyiWHwDA3GstLI1EAoPmP
sLG4ixIrJOtWKEXvpcI7Qd4E
=A0QY
-----END PGP SIGNATURE-----

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.