I'm trying to convert nvarchar separated with a comma to int, but I have a problem. I tried to use PARSENAME(REPLACE()), and it works fine but takes a long time to execute the code. I have a lot of tables, but here is an example.
I have a column that has name value and nvarchar datatype like (222,333,55,666,777,111). Every number will return color id, and then I use a function that will take converted value into text like(red/blue/green/black/gray). I want to split the value and convert the result into an int.
I have a function called GetTextAllLevel(int value) that takes int id and returns text. For example, it will take the value 222 and return red.
Tabel.GeTextAllLevels(CAST (Replace(Value, ',','.')) AS int) AS Category
I get syntax error at "AS", and I don't know why. I tried the code below that works with only four ids also:
GetCategoryLongName(((PARSENAME(REPLACE((fieldValue), ',', '.'),1)))) AS Category,