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 : 13:52:52
Hi,

I have the sysn tax error but I really don't know how to correct it

Incorrect syntax near the keyword 'If'.
Line 19: Incorrect syntax near 'ParentOfficeCode'

thanks
=====================
INSERT INTO FieldOfficeInformation (
OfficeCode,
OfficeName,
OfficeTypeCode,
OfficeType,
ParentOfficeCode,
AreaOfficeCode,
RegionCode,
RegionLetter,
AreaNumber,
ReportsToOfficeCode,
RegionNumber
)

SELECT
FO.OCD as OfficeCode,
NM as OfficeName,
OFC.OFC_TYP as
OfficeTypeCode,
OFC_TYP_TXT as
OfficeType,
FO.PRNT_OCD as ParentOfficeCode,
FO.ADOCD as AreaOfficeCode,
FO.ROCD as RegionCode,
AREA.ROLTR as RegionLetter,
AREA.ADONUM as AreaNumber,
IIf (NZ ([ParentOfficeCode], " ")=" ",
[AreaOfficeCode],
[ParentOfficeCode]) as ReportsToOfficeCode,
RO.RONUM as RegionNumber

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




setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-22 : 13:56:48
iif() isn't a t-sql function; you could use a CASE statement there though.

setBasedIsTheTruepath
<O>
Go to Top of Page
   

- Advertisement -