Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
Creating Trigger on View
Creating Trigger on View
Rate Topic
Display Mode
Topic Options
Author
Message
shohelr2003
shohelr2003
Posted Saturday, January 05, 2013 2:51 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 11:07 PM
Points: 126,
Visits: 346
Dear,
I have a view that is comprised of multiple tables containing only today's data. I used only select statement in that view. Now I want to write a trigger on that view that when a new row is inserted, it will insert a row into another table.
What can I do for that? Please suggest me in your earlier time.
Regards,
Akbar
Post #1403208
e4d4
e4d4
Posted Saturday, January 05, 2013 4:19 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 3:33 PM
Points: 160,
Visits: 1,139
What exactly is your problem? According to
BOL
"A view can be referenced only by an INSTEAD OF trigger."
http://msdn.microsoft.com/en-us/library/ms189799%28v=sql.90%29.aspx
Post #1403211
Bhuvnesh
Bhuvnesh
Posted Sunday, January 06, 2013 7:26 AM
SSCrazy
Group: General Forum Members
Last Login: Thursday, June 13, 2013 7:03 AM
Points: 2,562,
Visits: 3,453
certainly , we can have trigger (instead of) but i will suggest to set the trigger on table.
-------Bhuvnesh----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #1403331
opc.three
opc.three
Posted Sunday, January 06, 2013 11:53 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 8:44 PM
Points: 6,826,
Visits: 11,948
Bhuvnesh (1/6/2013)
certainly , we can have trigger (instead of) but i will suggest to set the trigger on table.
That likely will not help the situation. There is unique value added to the system when an instead trigger is placed on a view that joins multiple tables. Namely that we can support inserts into that view where before, without the instead trigger, we could not.
From
http://msdn.microsoft.com/en-us/library/ms175521(v=sql.105).aspx
The primary advantage of INSTEAD OF triggers is that they enable views that would not be updatable to support updates. A view based on multiple base tables must use an INSTEAD OF trigger to support inserts, updates, and deletes that reference data in more than one table.
__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Believe you can and you're halfway there.
--Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler
--Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them.
--Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples.
--Giordy
Post #1403346
Bhuvnesh
Bhuvnesh
Posted Sunday, January 06, 2013 10:58 PM
SSCrazy
Group: General Forum Members
Last Login: Thursday, June 13, 2013 7:03 AM
Points: 2,562,
Visits: 3,453
opc.three (1/6/2013)
Bhuvnesh (1/6/2013)
certainly , we can have trigger (instead of) but i will suggest to set the trigger on table.
That likely will not help the situation. There is unique value added to the system when an instead trigger is placed on a view that joins multiple tables. Namely that we can support inserts into that view where before, without the instead trigger, we could not.
From
http://msdn.microsoft.com/en-us/library/ms175521(v=sql.105).aspx
The primary advantage of INSTEAD OF triggers is that they enable views that would not be updatable to support updates. A view based on multiple base tables must use an INSTEAD OF trigger to support inserts, updates, and deletes that reference data in more than one table.
diamond studded link ..thanks
-------Bhuvnesh----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #1403407
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.