Results 1 to 4 of 4

Thread: Executing DDL in a trigger

  1. #1
    Sanjay Guest

    Executing DDL in a trigger

    Dear All,
    I would like to execute a DDL statement(create table) in a trigger. The DDL statement is stored as a field in another table. I have read that sql statement into a variable of type varchar. How do I execute that sql statement.
    Thanks in advance

  2. #2
    sunthar Guest

    Executing DDL in a trigger (reply)

    Please Note Create Statement can not be included inside Trigger

    Sunthar


    ------------
    Sanjay at 11/15/00 4:40:17 AM

    Dear All,
    I would like to execute a DDL statement(create table) in a trigger. The DDL statement is stored as a field in another table. I have read that sql statement into a variable of type varchar. How do I execute that sql statement.
    Thanks in advance

  3. #3
    sunthar Guest

    Executing DDL in a trigger (reply)

    I can't recall whether there will be a problem if you create through the procedure but I will give you the syntax as you requested. It is very simple

    General
    CREATE TABLE table_name
    ( field1 Integer/Varchar/Text Size Nul/Not null
    ....
    .....
    )


    To be specific
    CREATE TABLE member
    (member_no char 10 NOT NULL,
    lastname char 20 NOT NULL,
    )


    Please read Books On line which comes along with SQL Server CD. Mostly it need bit of play in SQL Server. I am also learnt most by playing on sql server. It is mearly learning to drive the car. More you drive more expert you be. Any way My recommended books are below

    ISBN 1-57231-826-0 SQL Server 7.0 Database Implementation Self Peaced Training.

    Regards
    Sunthar



    ------------
    Sanjay at 11/15/00 11:39:05 AM

    Thanks sunthar. Is it possible to do the same in a procedure. If yes then kindly give me the syntax for it.


    ------------
    sunthar at 11/15/00 5:40:45 AM

    Please Note Create Statement can not be included inside Trigger

    Sunthar


    ------------
    Sanjay at 11/15/00 4:40:17 AM

    Dear All,
    I would like to execute a DDL statement(create table) in a trigger. The DDL statement is stored as a field in another table. I have read that sql statement into a variable of type varchar. How do I execute that sql statement.
    Thanks in advance

  4. #4
    Sumit Guest

    Executing DDL in a trigger (reply)


    If you want to know how to execute a statement which is stored inside a variable then you can use Execute command.

    For example :-
    Exec(@myvar)

    You would need to do this from inside the Stored Proc instead of a trigger.

    ------------
    Sanjay at 11/15/00 4:40:17 AM

    Dear All,
    I would like to execute a DDL statement(create table) in a trigger. The DDL statement is stored as a field in another table. I have read that sql statement into a variable of type varchar. How do I execute that sql statement.
    Thanks in advance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •