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

后端 未结 4 1130
傲寒
傲寒 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:08

    This is one of those situations where it can be easier and faster to just use the diagram feature of SQL Server Management Studio.

    1. Create a new diagram, add your table, and choose to show the formula column in the diagram's table view.
    2. Change the columns formula to an empty string ('') or something equally innocuous (probably such that you don't change the column's datatype).
    3. Save the diagram (which should save the table).
    4. Alter your function.
    5. Put the function back in the formula for that column.
    6. Save once again.

    Doing it this way in SSMS will retain the ordering of the columns in your table, which a simple drop...add will not guarantee. This may be important to some.

提交回复
热议问题