SQLTeam.com | Weblogs | Forums

Automatic insert

I have a view in my database where data is stored, it has 2 columns (ID and value) and 3 rows (ID1, 2 and 3), the ID never changes but the value column of this ID always has a new value (e.g. ID : 1 value : False; ID :2 value : 55), the ID1 always changes from True to False and ID2 and 3 always have new values
I have created a new table with 2 columns (ID and Value).
I want to write a program that every time the value of ( ID 1 ) changes from False to True in the view, a new row is automatically inserted in the new table with the value of ID2 and ID3).

this is my program :
INSERT INTO Table1 ( ID,Value )
SELECT dbo.View1.Value , View_1.Value ,
dbo.View1 AS View1_1

WHERE (dbo.View1ID = 2)AND (View1_1.ID = 3)

it does what I want, but only when I run the program, I want this insert function to happen automatically every time the ID1 in the view changes from false to true. can you please help me

try looking into putting that into a trigger although I'd caution you that triggers aren't always performant and can cause locking, etc...