I've looked up the CASE syntax for similar scenarios and other issues people have had and can't find this one specifically. This is giving me a syntax error near the comma after the first case statement and I can't figure out why.
insert into usmas_Doors_HardwarePrepCodes(HWTypeMask, PrepTypeMask)
select
(
CASE HWType
WHEN NULL THEN 0
WHEN 'BT' THEN 1
WHEN 'CL' THEN 2
WHEN 'DB' THEN 3
WHEN 'ED' THEN 4
WHEN 'FB' THEN 5
WHEN 'HG' THEN 6
WHEN 'LK' THEN 7
WHEN 'SK' THEN 8
WHEN 'VW' THEN 9 END,
CASE
WHEN PrepType IS NULL AND Cutout = 0 THEN 0
WHEN PrepType = 'A' AND Cutout = 0 THEN 1
WHEN PrepType = 'H' AND Cutout = 0 THEN 2
WHEN PrepType = 'L' AND Cutout = 0 THEN 4
WHEN PrepType IS NULL AND Cutout = 1 THEN 1024
WHEN PrepType = 'A' AND Cutout = 1 THEN 1025
WHEN PrepType = 'H' AND Cutout = 1 THEN 1026
WHEN PrepType = 'L' AND Cutout = 1 THEN 1028 END
)
from HardwarePrepCodes
Any ideas?
EDIT: Have tried "END AS [ColumnName]" and that just throws syntax error near AS
(
and the)
– Hogan Aug 16 '17 at 20:13(
and)
around field list. Now are you sure why? – Hogan Aug 16 '17 at 20:15SELECT (column1, column2...) FROM
You can't encapsulate multiple columns in parenthesis like that. – Jacob H Aug 16 '17 at 20:16