2

If I have a table MyTable like this:

Value1 decimal

Then I have a view MyView:

Select SUM(Value1) as SumValue1 from MyTable

When I look at the view's column data type in SSMS under the view's columns section it is a decimal.

Now if I modify the table to:

Value1 real

If I refresh the view's column section in SSMS the data type is still a decimal. Now if I open the view and resave it, the datatype becomes a float.

Is this how it is supposed to be? It seems that the view doesn't change until I resave it.

4

1 に答える 1

7

はい、これは想定内です。ビューを完全に無効にする方法でテーブルを変更できます。これを回避したい場合は、ビューの作成時にWITH SCHEMABINDINGオプションを使用できます。リンクされた記事から:

基になるテーブルまたはテーブルのスキーマにビューをバインドします。SCHEMABINDING が指定されている場合、ビュー定義に影響を与えるような方法でベース テーブルを変更することはできません。ビュー定義自体を最初に変更または削除して、変更するテーブルへの依存関係を削除する必要があります。

于 2012-11-03T01:23:35.003 に答える