Re: Newbie Question - Creating Triggers within Stored Procedures

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

anonymous_at_discussions.microsoft.com
Date: 08/06/04


Date: Fri, 6 Aug 2004 14:45:06 -0500

Aaahhhh...thank you, Andrew.

Take care.

"Andrew J. Kelly" <sqlmvpnooospam@shadhawk.com> wrote in message
news:u73RI1%23eEHA.1764@TK2MSFTNGP10.phx.gbl...
> You can't have a GO in the stored procedure code. You can wrap each of
the
> pieces (table creation and trigger etc) in Dynamic sql though.
>
> EXEC('CREATE TABLE.....')
>
> EXEC('CREATE TRIGGER ...')
>
>
> --
> Andrew J. Kelly SQL MVP
>
>
> <anonymous@discussions.microsoft.com> wrote in message
> news:OCOXtr%23eEHA.4092@TK2MSFTNGP10.phx.gbl...
> > I have a migration procedure that fires off dozens of other stored
> procedure
> > to create tables, relationships, etc. Can I also create triggers on
those
> > newly-created tables by using those same procedures? I tried syntax
> similar
> > to below, but it of course didn't work.
> >
> > Thank you
> >
> > \\\
> > ALTER PROCEDURE dbo.usp_migrate_CreateTable8
> > AS
> > CREATE Table8
> > ...
> > ...
> > GO
> > CREATE TRIGGER Table8_INSERT ON Table8 FOR INSERT
> > AS
> > --<<Trigger code>>
> >
> > GO
> > ///
> >
> >
>
>



Relevant Pages

  • Re: lastmodified
    ... Andrew J. Kelly SQL MVP ... >> UPDATE YourTable SET = GETDATE ... >> Andrew J. Kelly SQL MVP ... >>> Can someone provide me a simple trigger where it updates a lastmodified ...
    (microsoft.public.sqlserver.security)
  • Re: which statement fire the trigger ?
    ... What I meant was you can see the events leading up to the trigger and then ... the trigger execution so you should be able to deduce what caused it. ... Andrew J. Kelly SQL MVP ... >> Andrew J. Kelly SQL MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Triggers and Data Driven Query
    ... I figured it was some kind of audit trail but I couldn't determine how this: ... You state you can see the trigger firing but you still don't say ... Andrew J. Kelly SQL MVP "David Fuller" wrote in message ...
    (microsoft.public.sqlserver.dts)
  • Re: TRANSACTION QUESTION
    ... a trigger you always have the deleted virtual table. ... Andrew J. Kelly SQL MVP ... > (Just like ORACLE does). ...
    (microsoft.public.sqlserver.programming)
  • Re: Trigger - Instead of Update
    ... Andrew J. Kelly ... > incide the trigger because it not longer exists. ... > GFID INT NOT NULL FOREIGN KEY REFERENCES GFON DELETE CASCADE ON ... >> UniqueId FROM inserted) ...
    (microsoft.public.sqlserver.programming)