Changing Column on existing Table

  • I have a table I need to change the precision value on a column. The current Size(Precision,Scale) is set to 5(7,4).  I would like it to be 9(11,4). I run the following script in SQL Analyzer

    ALTER TABLE pc_hdr

    {[ ALTER COLUMN pch_factor

        { decimal [ ( 9 [11 , 4 ] ) ] }}

    but get the error: [Microsoft][ODBC SQL Server Driver]Syntax error or access violation

    What am I doing wrong?

    Thanks...Nali

  • That works for me...

    CREATE TABLE #Demo (a DECIMAL(7, 4))

    INSERT INTO #Demo (a) VALUES (11)

    SELECT a FROM #Demo

    --11.0000

    ALTER TABLE #Demo

    ALTER COLUMN a DECIMAL(11, 6)

    SELECT a FROM #Demo

    --11.000000

    DROP TABLE #Demo

     

    Maybe you have a lock problem, or you need to give more information on the circumstances of the code.

  • Nali,

    Your syntax is wrong.  Use decimal(11,4).

    Greg

    Greg

  • Greg, that worked, thanks.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply