Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Help_Me
Starting Member
3 Posts |
Posted - 2012-01-30 : 00:19:11
|
CREATE TRIGGER TestUpdateON oil.T_DIST AFTER INSERTASIF (oil.T_DIST.SUBJECT = 'CONCRETE DRAWING' AND oil.O_DESD.TITLE = 'CONCRETE DRAWING')BEGININSERT INTO dbo.Test (Test)VALUES ('Test')ENDBasically, what im trying to do is if the Subject column in the T_DIST table is 'CONCRETE DRAWING' AND the TITLE column in the O_DESD table is 'CONCRETE DRAWING' then insert a new record into dbo.TestWhats wrong with the IF statement? |
|
sql-programmers
Posting Yak Master
190 Posts |
Posted - 2012-01-30 : 00:51:45
|
You can not use oil.T_DIST.SUBJECT or oil.O_DESD.TITLE in IF Statement..You can get inserted value like SELECT * FROM Inserted table. at the same time you used O_DESD table, This is not possible to get two table's inserted values at the same time. You can get only Triggered Table values using INSERTED table.SQL Server Programmers and Consultantshttp://www.sql-programmers.com/ |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-30 : 11:44:35
|
it should beCREATE TRIGGER TestUpdateON oil.T_DIST AFTER INSERTASBEGINIF EXISTS(SELECT 1FROM INSERTED WHERE SUBJECT = 'CONCRETE DRAWING' AND TITLE = 'CONCRETE DRAWING')BEGININSERT INTO dbo.Test (Test)VALUES ('Test')ENDEND ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|