1

I want to split a string and get the value after the space and am using below query. However i am getting an error that CHARINDEX is not valid. Are there any ways i can get around this?enter image description here

SELECT  productname,
SUBSTRING(productname, instr(' ', productname) +9, 50) AS ShortProductName       
FROM   ar_cem_financedb_analytics_finance.dimproduct
forpas
  • 160,666
  • 10
  • 38
  • 76
Adam
  • 45
  • 4

1 Answers1

2

Hive does not support SQL Server's CHARINDEX() function.

In your 2nd query you are using INSTR() but the arguments are reversed.
Change to:

SUBSTRING(productname, instr(productname, ' ') +9, 50)

or use LOCATE():

SUBSTRING(productname, locate(' ', productname) +9, 50)
forpas
  • 160,666
  • 10
  • 38
  • 76