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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Theoretically speaking...

Author  Topic 

DavidChel
Constraint Violating Yak Guru

474 Posts

Posted - 2008-09-16 : 15:51:33
If I were creating a trigger such as:

CREATE TRIGGER SOMEAUDIT
ON DATBASENAME.DBO.SOMETABLE
AFTER UPDATE,INSERT,DELETE
AS
SET NOCOUNT ON

BEGIN

Insert DifferentDatabase.Dbo.SomeOtherTable
field1,
field2,
field3,
....

SELECT DIFFERENTDATABASE.DBO.FIELDA,
DIFFERENTDATABASE.DBO.FIELDB DIFFERENTDATABASE.DBO.FIELDC

FROM Inserted
INNER JOIN SOME3RDTABLE
ON Inserted.field1 = SOME3RDTABLE.B
INNER JOIN SOME4THTABLE
ON SOME3RDTABLE.C = SOME4THTABLE.D
WHERE SOME3RDTABLE.Z = 'bleh'
END


Does it matter how long the insert and select sections are if the Inner Joins and Where statement return no records anyway?




X002548
Not Just a Number

15586 Posts

Posted - 2008-09-16 : 15:55:06
Weel do a showplan, but I believe the WHERE Predicate is applied before the join predicate

In any case, it doesn't make much sense in the first place

You don't reference inserted or deleted



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

DavidChel
Constraint Violating Yak Guru

474 Posts

Posted - 2008-09-16 : 15:57:23
quote:
Originally posted by X002548

Weel do a showplan, but I believe the WHERE Predicate is applied before the join predicate

In any case, it doesn't make much sense in the first place

You don't reference inserted or deleted



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam






Sorry, I fixed it. Umm.. stupid question, how do I do a show plan?
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-09-16 : 16:42:14
If you're running the query in management studio/query analyser, select the 'show execution plan' option. In management studio that's Query->Include actual execution plan (or Ctrl-M)

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -