0

I thought below would work:

strSQL = "ALTER TABLE table1 ADD COLUMN weighted_score AS (IS NOT NULL(score='H')*2 + IS NOT NULL(score='L')*1 )

but I get

"Syntax error in field definition" 3292

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
  • 1
    Please tag your question with the database that ou are running: mysql, oracle, sql-server...? – GMB Apr 06 '20 at 17:37
  • You are adding a **column**. You cannot assign any values to individual rows until table modification has been completed. – PM 77-1 Apr 06 '20 at 17:37
  • Depending on the database you use you might be able to setup a default value for a **new** row. – PM 77-1 Apr 06 '20 at 17:38
  • What are you trying to do? I can't figure out what that code attempt is supposed to do. – jarlh Apr 06 '20 at 17:53
  • I don't think ALTER TABLE can handle creating a Calculated type field. Might be able to with TableDefs. Why would you need code to modify table design? Do this table edit manually or better, do calculation in SELECT query. – June7 Apr 06 '20 at 18:06

0 Answers0