Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Trigger on views

$
0
0

Hi, I have following tables and a view:
TableStaff (UserId,Username,Firstname,Lastname)

TableFeatures (UserId,Option,Notes,LogDate)

TableExport( UserId,Username,Firstname,Lastname,Feature,Notes)

ViewStaff( UserId,Username,Firstname,Lastname, Feature,Notes)

Is it possible to create a trigger onViewStaff which can do following:

When data is inserted with the "Feature" column then it will copy UserId, Username, Firstname, Lastname, Option, Notes to theTableExport.

I have tried following, however when data is inserted it is not copying to the TableExport

SQL
CREATETRIGGERtrig_Staff1ONViewStaffINSTEADOFINSERTASBEGININSERTINTOTableExport(UserId,Username,Firstname,Lastname,Feature,Notes)SELECTUserId,Username,Firstname,Lastname,Feature,NotesfromInsertedEND

Any help would be much appreciated, thank you.


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>