Link to home
Start Free TrialLog in
Avatar of isames
isames

asked on

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?
Avatar of Wayne88
Wayne88
Flag of Canada image

ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial