我有 3 个表需要从中提取数据,这些数据取决于其他表的结果,因此我尝试使用 if then else 结构并遇到语法错误。就 SQL 专业知识而言,我可能会不知所措。我在第一个 if 附近生成一个语法错误,随后在每个 then 附近生成一个语法错误。这是一个简单的语法错误还是我试图做一些 MS SQL 2000 无法处理的事情?
谢谢您的意见。
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
Go
Begin
Declare @vCasinoName varchar(35)
select @vCasinoName = Description from Gen_Casino
Create Table #AG_Report
(Slotnumber int,
SRID varchar(30),
SerialNumber varchar(15),
CAsset varchar(30),
Mfr varchar(15),
Denomination numeric(12, 2),
Description varchar(30),
Par real,
EPROMID varchar(15),
EPROMID2 varchar(15),
EPROMIDXL varchar(30),
Jurisdiction varchar(30),
Bios varchar(30),
BootChip varchar(30),
VersionChip varchar(30),
CasinoName varchar(35),
)
insert into #AG_Report
select s.SlotNumber,
s.SerialNumber,
m.Manufacturer,
s.Denomination,
s.Description,
s.Par,
s.EPROMID,
s.EPROMID2,
if (CF.FieldID = 6)
BEGIN
CF.Value as SRID,
END
else if (CF.FieldID = 7)
BEGIN
CF.Value as CAsset,
END
else if (CF.FieldID = 9)
BEGIN
else if (CF.FieldID = 9)
BEGIN
CF.value as EPROMIDXL,
else if (CF.FieldID = 13)
BEGIN
CF.Value as Jurisdiction,
END
else if (CF.FieldID = 11)
BEGIN
CF.Value as Bios,
END
else if (CF.FieldID = 12)
BEGIN
CF.Value as BootChip,
END
else if (CF.FieldID = 14)
BEGIN
CF.Value as VersionChip,
END
from CDS_Slotmast S, BB_SlotMastCustomField CF,BB_Mfr M,
where S.SlotMast_id = CF.SlotMast_ID
and CF.Revision = S.Revision
and S.Active = "Y"
order by s.Denomination, s,SlotNumber
Select * from #AG_Report
End