DmitriBodiu
DmitriBodiu

Reputation: 1210

Computed column of type Date in sql

I have parameters column in my db. It contains different params as varchar including "BestBeforeDate". Now I want to be able to filter the rows based on BestBeforeDate. I'm trying to create a computed column of type 'Date' and then index it. I do:

alter table stocklines add BestBeforeDate as CONVERT(date, JSON_VALUE(Parameters, '$.BestBeforeDate'), 112) persisted

and I'm getting an error: JSON text is not properly formatted. Unexpected character '.' is found at position 22. but I don't have any dots in my Best BeforeDate json property...enter image description here

Table Design: enter image description here

Upvotes: 0

Views: 187

Answers (1)

DmitriBodiu
DmitriBodiu

Reputation: 1210

The problem was that one of my Properties columns containes an invalid Json: "{ Param4: "54"" and then no closing Square bracket... its interresting why the exception said '.' is unexpected character though. There are no any dots in Parameters column for every row...

Upvotes: 1

Related Questions