-
More Help with Trigger.
Newbie.
Create an update Trigger on the Carrier Table that will display the all the fields and records in the Inserted, Deleted, and Carrier Table.
This is the Table.
Create Table Paper
(
PaperID smallint identity(1,1) Not Null /* a paper id can not be blank. Data has to be there*/
Constraint PK_Paper Primary Key Clustered,
PaperName varchar(30) Not Null
)
Thanks,
Last edited by calthi; 07-18-2005 at 10:41 AM.
-
You can do select * on inserted and deleted tables. But if you do select * on carrier table then you will get all the rows not just the updated rows. to get only the updated rows, you have to join it with inserted or deleted table.
-
Triggers do not return data to the user!! If you are tryting to get the trigger to display data for you, it won't work.
-
Wow, I did not know that Trigger do not return data to the user. But this question is used by my instructor for the lab. Humm????
-
What is the exact question from the instructor?
And to correct myself, a trigger SHOULD NOT return any results back to the user, but it is basically just a stored procedure, so it will return results back like any other stored procedure.
An instructor should not be teaching you to do this however!!!!
-
The question is like this:
Create an update Trigger on the Carrier Table that will display the all the fields and records in the Inserted, Deleted, and Carrier Table.
-
Well, it will work, it just isn't something you should do.
I would do it using a Union query. I would also add a column to tell which
Select 'Inserted' as TableName, *
From Inserted
Union
Select 'Deleted' as TableName, *
From Deleted
Union
Select 'Carrier' as TableName, *
From Carrier
If you only want to return the records affected by the update then Join the Carrier table to either the inserted or deleted table, it doesn't matter which.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|