If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Syntax error in append query
Hello,
I can not save my following append query, with the error message " Syntax error on INSERT INTO statement. I presume because I wrongly name my field " Region Name_E" with space. How can I remedy this, my church database already go live, how ever I want to make kind of an append query for update when there is a consolidation. Thanks for any help, Frank INSERT INTO tblRegions ( RegionID,Region Name_E, Region Name_L, RAddress1, RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress) SELECT a.RegionID, a.Region Nam_E, a.Region Name_L, a.RAddress1, a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax, a.RemailAddress FROM [C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.md b].tblRegions AS a WHERE (((Exists (SELECT * FROM tblRegions WHERE tblRegions.RegionID = a.RegionID))=False)); |
#2
|
|||
|
|||
Syntax error in append query
Frank,
Whenever you have a space in a table or field name, you must wrap it in brackets [ ]. I also think it will probably be more efficient to use an Outer Join to identify the regions that don't already exist in the table you are trying to insert into. So, try: INSERT INTO tblRegions (RegionID,[Region Name_E], [Region Name_L], RAddress1, RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress) SELECT a.RegionID, a.[Region Nam_E], a.[Region Name_L], a.RAddress1, a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax, a.RemailAddress FROM tblRegions IN "C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.m db" AS a LEFT JOIN tblRegions ON a.RegionID = tblRegions.RegionID WHERE tblRegions.RegionID IS NULL HTH Dale Frank Situmorang wrote: Hello, I can not save my following append query, with the error message " Syntax error on INSERT INTO statement. I presume because I wrongly name my field " Region Name_E" with space. How can I remedy this, my church database already go live, how ever I want to make kind of an append query for update when there is a consolidation. Thanks for any help, Frank INSERT INTO tblRegions ( RegionID,Region Name_E, Region Name_L, RAddress1, RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress) SELECT a.RegionID, a.Region Nam_E, a.Region Name_L, a.RAddress1, a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax, a.RemailAddress FROM [C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.md b].tblRegions AS a WHERE (((Exists (SELECT * FROM tblRegions WHERE tblRegions.RegionID = a.RegionID))=False)); -- HTH Dale Fye Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...eries/200907/1 |
#3
|
|||
|
|||
Syntax error in append query
Thanks Dale, since I have a button for running an append query, I think I
would prefer to use append query. Thanks for your help. Frank "Dale_Fye via AccessMonster.com" wrote: Frank, Whenever you have a space in a table or field name, you must wrap it in brackets [ ]. I also think it will probably be more efficient to use an Outer Join to identify the regions that don't already exist in the table you are trying to insert into. So, try: INSERT INTO tblRegions (RegionID,[Region Name_E], [Region Name_L], RAddress1, RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress) SELECT a.RegionID, a.[Region Nam_E], a.[Region Name_L], a.RAddress1, a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax, a.RemailAddress FROM tblRegions IN "C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.m db" AS a LEFT JOIN tblRegions ON a.RegionID = tblRegions.RegionID WHERE tblRegions.RegionID IS NULL HTH Dale Frank Situmorang wrote: Hello, I can not save my following append query, with the error message " Syntax error on INSERT INTO statement. I presume because I wrongly name my field " Region Name_E" with space. How can I remedy this, my church database already go live, how ever I want to make kind of an append query for update when there is a consolidation. Thanks for any help, Frank INSERT INTO tblRegions ( RegionID,Region Name_E, Region Name_L, RAddress1, RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress) SELECT a.RegionID, a.Region Nam_E, a.Region Name_L, a.RAddress1, a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax, a.RemailAddress FROM [C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.md b].tblRegions AS a WHERE (((Exists (SELECT * FROM tblRegions WHERE tblRegions.RegionID = a.RegionID))=False)); -- HTH Dale Fye Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...eries/200907/1 |
Thread Tools | |
Display Modes | |
|
|