on delete cascade problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hilz

    #1

    on delete cascade problem

    Hi all
    I am trying to create a relation between two tables.

    this is the sql statement in question

    alter table T1
    add constraint relation_T1_to_ T2
    foreign key (T2_ID)
    references T2 (ID) on delete cascade;

    This relation is created fine if i execute the SQL statement using a
    connection to the database.
    but if i open the datbase in MSACCESS and open the query build, switch
    to the sql view, and perform it, it complains about a syntax error at
    the word "delete".

    does anyone know why that is?

    thanks
  • hilz

    #2
    Re: on delete cascade problem

    hilz wrote:[color=blue]
    > Hi all
    > I am trying to create a relation between two tables.
    >
    > this is the sql statement in question
    >
    > alter table T1
    > add constraint relation_T1_to_ T2
    > foreign key (T2_ID)
    > references T2 (ID) on delete cascade;
    >
    > This relation is created fine if i execute the SQL statement using a
    > connection to the database.
    > but if i open the datbase in MSACCESS and open the query build, switch
    > to the sql view, and perform it, it complains about a syntax error at
    > the word "delete".
    >
    > does anyone know why that is?
    >
    > thanks[/color]

    no takers?

    Comment

    • Trevor Best

      #3
      Re: on delete cascade problem

      hilz wrote:[color=blue]
      > hilz wrote:
      >[color=green]
      >> Hi all
      >> I am trying to create a relation between two tables.
      >>
      >> this is the sql statement in question
      >>
      >> alter table T1
      >> add constraint relation_T1_to_ T2
      >> foreign key (T2_ID)
      >> references T2 (ID) on delete cascade;
      >>
      >> This relation is created fine if i execute the SQL statement using a
      >> connection to the database.
      >> but if i open the datbase in MSACCESS and open the query build, switch
      >> to the sql view, and perform it, it complains about a syntax error at
      >> the word "delete".
      >>
      >> does anyone know why that is?
      >>
      >> thanks[/color]
      >
      >
      > no takers?[/color]

      I assume the back-end database is something like SQL Server?

      Access SQL is slightly different to T-SQL, if you made your query a
      "pass through" one it would probably work apart from the fact you
      already created the constraint so it would probably complain about that :-)

      Comment

      • Chris2

        #4
        Re: on delete cascade problem


        "hilz" <now@y.com> wrote in message
        news:eUA8f.4995 $UM1.1460@duker ead10...[color=blue]
        > hilz wrote:[color=green]
        > > Hi all
        > > I am trying to create a relation between two tables.
        > >
        > > this is the sql statement in question
        > >
        > > alter table T1
        > > add constraint relation_T1_to_ T2
        > > foreign key (T2_ID)
        > > references T2 (ID) on delete cascade;
        > >
        > > This relation is created fine if i execute the SQL statement using[/color][/color]
        a[color=blue][color=green]
        > > connection to the database.
        > > but if i open the datbase in MSACCESS and open the query build,[/color][/color]
        switch[color=blue][color=green]
        > > to the sql view, and perform it, it complains about a syntax error[/color][/color]
        at[color=blue][color=green]
        > > the word "delete".
        > >
        > > does anyone know why that is?
        > >
        > > thanks[/color]
        >
        > no takers?[/color]

        hilz,

        You may not execute CASCADE clauses via MS Access Query Objects.

        I *believe* you must use DAO and execute the SQL directly.


        Sincerely,

        Chris O.


        Comment

        Working...