Note that there are some explanatory texts on larger screens.

plurals
  1. POIf Then Else syntax in MS SQL Server 2000
    text
    copied!<p>I have 3 tables that I need to pull data from, that data is dependant on the results from the other tables, so I am trying to use an if then else structure and am getting syntax errors. I may be over my head as far as SQL expertise goes. I generate a syntax error near the first if and subsequently near each then. Is this a simple syntax error or am I trying to do something MS SQL 2000 is incapable of handling?</p> <p>Thank you for your input.</p> <pre><code>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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload