SQL Query

My BI software is sending the following query to SQL server.

SELECT [SalesImportHistoryV2].[CLASS_DESC],SUM((Case
 When SalesImportHistoryV2.RSID_TYPE = 'S'
 Then SalesImportHistoryV2.RSID_EXTENDED
 Else NULL
 End)) as FLD0000005 ,Min(COALESCE('',''))
 from TSIProd.tsi.SalesImportHistoryV2 SalesImportHistoryV2 LEFT JOIN TSIProd.tsi.GLDV GLDV ON  [SalesImportHistoryV2].[STORE_NUM] = [GLDV].[GLDV_ALT_DIV_N] LEFT JOIN TSIProd.tsi.MetroLocation MetroLocation ON  [GLDV].[GLDV_ALT_DIV_N] = [MetroLocation].[StoreNumber] LEFT JOIN TSIProd.tsi.ARCF ARCF ON  [SalesImportHistoryV2].[Customer_Number] = [ARCF].[ARCF_CUST_N] and  [SalesImportHistoryV2].[Parent_Name] = [ARCF].[ARCF_NAME]
 where ([SalesImportHistoryV2].[RSID_TYPE] <> 'L') and (Year([SalesImportHistoryV2].[RSIH_DATE])) IN  (2015) AND (Month([SalesImportHistoryV2].[RSIH_DATE]))  <Month(Getdate())    AND [SalesImportHistoryV2].[RSIH_DATE] >= '2014-01-01T00:00:00' AND  ([SalesImportHistoryV2].[RSID_TYPE] = 'S') AND [Case
When gldv_alt_div_n in ('1120', '1125', '1170', '1203', '1207', '1209', '1213', '1214', '1215', '1218', '1260', '1267', '1274', '1308', '1410', '1412', '1453', '1457', '1460', '1474', '1475', '1478', '1482', '1521', '1751', '1752', '1753', '1968', '1970', '1979', '1980', '1981', '2205', '3201', '3202', '3401', '6003', '1176', '1467', '1382', '1273', '1451', '1281', '1967', '1127')
then '1400 South'
Else
Case
When gldv_alt_div_n in ('1101', '1106', '1109', '1186', '1187', '1220', '1221', '1232', '1301', '1302', '1303', '1304', '1311', '1314', '1321', '1322', '1354', '1356', '1360', '1361', '1368', '1369', '1373', '1375', '1379', '1802', '1955', '1957', '1969', '1972', '1975', '1977', '3101', '3102', '3103', '3301', '3302', '7201', '7202', '7203', '7204', '7205', '7206', '7207')
then '1300 North'
Else '1700 West'
End
End] = '1700 West'
 group by [SalesImportHistoryV2].[CLASS_DESC]



I get the following error:
Msg 103, Level 15, State 4, Line 7
The identifier that starts with 'Case
When gldv_alt_div_n in ('1120', '1125', '1170', '1203', '1207', '1209', '1213', '1214', '1215', '1218', '1260', '1267', '12' is too long. Maximum length is 128.


I've used this case statement numerous times for other reasons, why would it give me this error this time?
LVL 1
isamesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne88Commented:
Scott PletcherSenior DBACommented:
You have to remove the extra brackets, []:

AND /*[*/Case
 When gldv_alt_div_n in ('1120', '1125', '1170', '1203', '1207', '1209', '1213', '1214', '1215', '1218', '1260', '1267', '1274', '1308', '1410', '1412', '1453', '1457', '1460', '1474', '1475', '1478', '1482', '1521', '1751', '1752', '1753', '1968', '1970', '1979', '1980', '1981', '2205', '3201', '3202', '3401', '6003', '1176', '1467', '1382', '1273', '1451', '1281', '1967', '1127')
 then '1400 South'
 Else
 Case
 When gldv_alt_div_n in ('1101', '1106', '1109', '1186', '1187', '1220', '1221', '1232', '1301', '1302', '1303', '1304', '1311', '1314', '1321', '1322', '1354', '1356', '1360', '1361', '1368', '1369', '1373', '1375', '1379', '1802', '1955', '1957', '1969', '1972', '1975', '1977', '3101', '3102', '3103', '3301', '3302', '7201', '7202', '7203', '7204', '7205', '7206', '7207')
 then '1300 North'
 Else '1700 West'
 End
 End/*]*/ = '1700 West'

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.