0

I have a table (rugs) that has columns for length and width (both 2 place decimals).

I'm trying to create a computed column named area which simply multiplies the length by width to generate the area but hitting syntax errors when running the query.

My attempted code using mySQL was as follows:

alter table `rugs` add `area` as (`length` * `width`) PERSISTED

But it's not liking the syntax, getting a #1064 error

1 Answers1

1

In MySQL, the syntax is:

alter table rug add area generated always as (length * width) stored;

The documentation explains the syntax.

Your syntax is more appropriate for SQL Server.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786