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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 trigger

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-07-13 : 10:14:55
grace writes "I am using SLQ Enterprise Manager version8.0
I have a very smiple table myT2 with two fileds SID and SSN with 2 rows:

SID SSN
----------
0 22
1 33

Here is a simple trigger I wrote:

ALTER TRIGGER myTrigger ON [dbo].[myT2]
INSTEAD OF INSERT, UPDATE
AS
begin
select * from Inserted
select * from Inserted
left outer join Deleted
on Inserted.SSN = Deleted.SSN

select * from Deleted
end

Then I have 2 simple store proc with insert and update statment.
Now I run the debugger to get into the trigger. Here is the problem:

For update there is no problem, I input SID=0 SSN=2. The result fot the trigger is

SID SSN
--------
0 22

SID SSN SID SSN
------------------
0 22 0 2

SID SSN
---------
0 2

So this is a result which I expected.

The problem occures when I step into the trigger with Insert. I try to insert a new row SID=4, SSN=5. The result is:

SID SSN
--------
4 5

SID SSN SID SSN
------------------

SID SSN
---------

With the left outer join, it should return some value for the second select statement.
There seems no problem when I run it on other DB instance (even I cant use debugger to step into the trigger, but I see the correct result.
Here comes another question, why I am only able to debug sql with the local instance, not able to debug with other db instance?).

Does this have anything to do with the SQL setting?


Any idea will be appriciate.
Thank you in advance,
Grace"
   

- Advertisement -