Dynamic SQL generation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    #16
    Originally posted by ck9663
    Create a view with all the columns you need. Create a trigger for that view to handle the insert to all tables. Use Transaction processing so that you can rollback if one of the insert fails.

    -- CK
    i created a trigger for the update of the 2 tables in question

    [CODE=sql]ALTER trigger [dbo].[InsEmployee] on [dbo].[Employee]
    after update
    as
    if not exists(select s.employeeID , e.firstname , e.Lastname , s.wages from employee e, salary s where e.employeeid = s.employeeid)
    begin
    raiserror('the employee does not exist',16,1)
    rollback transaction
    End[/CODE]

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #17
      Create a trigger on the view. Not on the table.

      Create the trigger on the view. Inside that trigger, that's where you UPDATE all the tables.

      -- CK

      Comment

      Working...