1

私は-SQLサーバーでビューを作成します。テーブルに行が追加されるたびに、ビューを変更したいと考えています。私はそれのためのトリガーを作成します:

CREATE TRIGGER Trigger1
ON dbo.Table1
AFTER INSERT
AS 
BEGIN
ALTER VIEW VIEW1 as
SELECT *
From Table1
END

しかし、エラーが発生します:「ALTER VIEW」はバッチ内の唯一のステートメントでなければなりません。

エラーを修正するにはどうすればよいですか?

4

1 に答える 1

0

WHY do you want to alter your view every time a row is inserted? That doesn't make any sense at all!

The view doesn't contain (or store) the rows it shows - it's just a stored query...

It will always go to the base table and fetch the data again, when you select from it. There's really no need to constantly alter the view!

It will show that row after it's been inserted without being altered...

于 2012-11-07T09:35:28.867 に答える