How can I alter this computed column in SQL Server 2008?

后端 未结 4 1136
傲寒
傲寒 2020-12-07 00:23

I have a computed column created with the following line:

alter table tbPedidos 
add restricoes as (cast(case when restricaoLicenca = 1 or restricaoLote = 1          


        
4条回答
  •  庸人自扰
    2020-12-07 01:03

    Another thing that might be helpful to someone is how to modify a function that's a calculated column in a table (Following query is for SQL):

    ALTER 
    DROP COLUMN 
    
    ALTER FUNCTION 
    (
    
    )
    RETURNS 
    BEGIN
    ...
    END
    
    ALTER 
    ADD as dbo.(parameters)

    Notes:

    1. Parameters can be other columns from the table

    2. You may not be able to run all these queries at once, I had trouble with this. Run them one at a time

    3. SQL automatically populates calculated columns, so dropping and adding won't affect data (I was unaware of this)

    提交回复
    热议问题