locked
incorrect syntax near '('. RRS feed

  • Question

  • use [sbbc-budget]


    ALTER TABLE dbo.unf_schoolpositions
       DROP COLUMN unf_pos_Salary

    ALTER TABLE dbo.unf_schoolpositions ADD unf_pos_salary cast ((unf_1015_salary * 1.1) AS decimal (8,2)));

    Msg 102, Level 15, State 1, Line 7
    Incorrect syntax near '('.

    anybody have any clues???

       
    Wednesday, June 8, 2016 2:22 PM

Answers

  • Perhaps now is the time to lookup the correct syntax in BOL - and perhaps give your use of parentheses a closer look.  Your parentheses are not balanced - a problem you have yet to discover. And you are attempting to use the syntax for creating a standard column - where the datatype follows the name.  You need to include the keyword "as" in your statement. 

    alter table ... add col as ...

    Wednesday, June 8, 2016 3:30 PM

All replies

  • What are you trying to achieve?
    Wednesday, June 8, 2016 2:32 PM
  • trying to add a sql computed column with a decimal result of  (8,2) scale precision. It looks like a simple syntax error!!
    Wednesday, June 8, 2016 3:01 PM
  • I think you are setting default value to unf_pos_salary, what is the datatype of "unf_1015_salary"?
    Wednesday, June 8, 2016 3:16 PM
  • Perhaps now is the time to lookup the correct syntax in BOL - and perhaps give your use of parentheses a closer look.  Your parentheses are not balanced - a problem you have yet to discover. And you are attempting to use the syntax for creating a standard column - where the datatype follows the name.  You need to include the keyword "as" in your statement. 

    alter table ... add col as ...

    Wednesday, June 8, 2016 3:30 PM
  • Well for starters at the end of the command you've got three closing brackets when you only need two.

    ALTER TABLE dbo.unf_schoolpositions ADD unf_pos_salary cast ((unf_1015_salary * 1.1) AS decimal (8,2));


    Please click "Mark As Answer" if my post helped. Tony C.

    Wednesday, June 8, 2016 3:38 PM