Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query

Author  Topic 

vicki
Posting Yak Master

117 Posts

Posted - 2002-03-22 : 08:30:21
Hi,

With the query below why do I got error for invalid 'RegionCode'?

Thanks

INSERT INTO AreaInformation
(OfficeCode,
OfficeName,
OfficeTypeCode,
OfficeType,
RegionCode,
RegionLetter,
AreaNumber,
RegionNumber,
RegionAcronym,
ReportsToOfficeCode,
OfficeStartDate,
OfficeEndDate,
OfficeReopeningDate,
Timezone,
Email,
PhysicalAddressLine1,
PhysicalAddressLine2,
PhysicalAddressLine3,
PhysicalAddressLine4,
PhysicalAddressCity,
PhysicalAddressState,
PhysicalAddressZip,
MailingAddressLine1,
MailingAddressLine2,
MailingAddressLine3,
MailingAddressLine4,
MailingAddressCity,
MailingAddressState,
MailingAddressZip,
AdminPhone,
AdminPhoneExt,
AdminFax,
AdminFaxExt,
BusPhone,
BusPhoneExt,
BusFax,
BusFaxExt,
EqpPhone,
EqpPhoneExt,
EqpFax,
EqpFaxExt,
T16Phone,
T16PhoneExt,
T16Fax,
T16FaxExt,
T2Phone,
T2PhoneExt,
T2Fax,
T2FaxExt,
TTYPhone,
TTYPhoneExt,
TTYFax,
TTYFaxExt,
EqpContact)
SELECT
AREA.OCD as OfficeCode,
NM as OfficeName,
OFC.OFC_TYP as OfficeTypeCode,
OFC_TYP_TXT as OfficeType,
AREA.ROCD as RegionCode,
AREA.ROLTR asRegionLetter,
AREA.ADONUM as AreaNumber,
RO.RONUM as RegionNumber,
RO.ROACR as RegionAcronym,
RegionCode as ReportsToOfficeCode,
OFC.STDT as OfficeStartDate,
OFC.ENDT as OfficeEndDate,
OFC.REOP_DT as OfficeReopeningDate,
OFC.TMZN_Txt as Timezone,
OfficeAddressInformation.Email,
OfficeAddressInformation.PhysicalAddressLine1,
OfficeAddressInformation.PhysicalAddressLine2,
OfficeAddressInformation.PhysicalAddressLine3,
OfficeAddressInformation.PhysicalAddressLine4,
OfficeAddressInformation.PhysicalAddressCity,
OfficeAddressInformation.PhysicalAddressState,
OfficeAddressInformation.PhysicalAddressZip,
OfficeAddressInformation.MailingAddressLine1,
OfficeAddressInformation.MailingAddressLine2,
OfficeAddressInformation.MailingAddressLine3,
OfficeAddressInformation.MailingAddressLine4,
OfficeAddressInformation.MailingAddressCity,
OfficeAddressInformation.MailingAddressState,
OfficeAddressInformation.MailingAddressZip,
OfficePhones.AdminPhone,
OfficePhones.AdminPhoneExt,
OfficePhones.AdminFax,
OfficePhones.AdminFaxExt,
OfficePhones.BusPhone,
OfficePhones.BusPhoneExt,
OfficePhones.BusFax,
OfficePhones.BusFaxExt,
OfficePhones.EqpPhone,
OfficePhones.EqpPhoneExt,
OfficePhones.EqpFax,
OfficePhones.EqpFaxExt,
OfficePhones.T16Phone,
OfficePhones.T16PhoneExt,
OfficePhones.T16Fax,
OfficePhones.T16FaxExt,
OfficePhones.T2Phone,
OfficePhones.T2PhoneExt, OfficePhones.T2Fax,
OfficePhones.T2FaxExt,
OfficePhones.TTYPhone,
OfficePhones.TTYPhoneExt,
OfficePhones.TTYFax,
OfficePhones.TTYFaxExt,
OfficePhones.EqpContact

FROM AREANew as AREA LEFT JOIN OFCNew as OFC ON AREA.OCD = OFC.OCD LEFT JOIN OCDASGNNew as OCDASGN ON OFC.OFC_TYP = OCDASGN.OFC_TYP
LEFT JOIN OfficeAddressInformation ON AREA.OCD =
OfficeAddressInformation.OCD
LEFT JOIN OfficePhones ON AREA.OCD = OfficePhones.OfficeCode
LEFT JOIN RONew as RO ON AREA.ROCD = RO.OCD


robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-22 : 08:33:50
Either the datatype for region code is different between the 2 tables, or there's a value that violates a constraint or foreign key for the region code column. Without a more detailed error message it's hard to tell.

Go to Top of Page
   

- Advertisement -