Forum Replies Created

Viewing 15 posts - 76 through 90 (of 101 total)

  • RE: delete cascade trigger

    Chim Kalunta (10/1/2009)


    Sure.

    ALTER TABLE [dbo].[ForeignKeyTable] WITH CHECK ADD CONSTRAINT [FK_ForeignKeyTable_PrimaryKeyTable] FOREIGN KEY([col_fk])

    REFERENCES [dbo].[PrimaryKeyTable] ([col_pk])

    ON DELETE CASCADE

    The key clause in the code above is the ON DELETE CASCADE. ...

  • RE: delete cascade trigger

    Chim Kalunta (10/1/2009)


    Would a simple Cascade Delete Foreign Key Relationship not work?

    would you be so kind to post an example.

  • RE: delete cascade trigger

    Steve Jones - Editor (9/29/2009)


    Yes, but be sure this is what you want. In a FK, you have to remove all children before you can remove a parent. Note that...

  • RE: delete cascade trigger

    Steve Jones - Editor (9/29/2009)


    You are trying to delete rows that have a FK reference. You need to delete the child rows before you can remove the parent.

    ok...so i have...

  • RE: delete cascade trigger

    Steve Jones - Editor (9/29/2009)


    This should work, providing that you have the proper columns linked. Note that you're writing an old style join, which is not recommended. You ought to...

  • RE: SP with substring

    igngua (9/29/2009)


    igngua (9/29/2009)


    igngua (9/29/2009)


    GSquared (9/29/2009)


    Before you jump in and try this on a production database, test it first on a copy of the data that you can replace if it...

  • RE: SP with substring

    igngua (9/29/2009)


    igngua (9/29/2009)


    GSquared (9/29/2009)


    Before you jump in and try this on a production database, test it first on a copy of the data that you can replace if it gets...

  • RE: SP with substring

    igngua (9/29/2009)


    GSquared (9/29/2009)


    Before you jump in and try this on a production database, test it first on a copy of the data that you can replace if it gets messed...

  • RE: SP with substring

    GSquared (9/29/2009)


    Before you jump in and try this on a production database, test it first on a copy of the data that you can replace if it gets messed up.

    thanks...

  • RE: SP with substring

    GSquared (9/29/2009)


    Is "desprod" the column you want to change?

    If so, try this first:

    select replace(desprod,left(desprod,PATINDEX('%/%',desprod)),'')

    from dbo.MyTable;

    You'll need to use the actual table name, where I have "MyTable".

    Does that give you a...

  • RE: SP with substring

    GSquared (9/28/2009)


    @result is just a variable being used for the sample code.

    You'd use your column name instead.

    Thanks!

    So the procedure looks like ;

    PROCEDURE [dbo].[limpiar]

    AS

    BEGIN

    declare @result varchar(20)

    select @result = 'desprod'

    select PATINDEX('%/%',@result)

    select...

  • RE: SP with substring

    GSquared (9/28/2009)


    Patindex finds the first place that the substring appears. It nests that in Left, which gets everything up to that point. Then it replaces that in the...

  • RE: SP with substring

    what should be @result value...that confused me ...

  • RE: SP with substring

    arun.sas (9/25/2009)


    declare @result varchar(20)

    select @result = 'testdb/sysdb'

    select PATINDEX('%/%',@result)

    select left(@result,PATINDEX('%/%',@result))

    select replace(@result,left(@result,PATINDEX('%/%',@result)),'')

    thanks !! i dont understand de meaning of this one ...

    "select @result = 'testdb/sysdb'"

  • RE: reference constraint

    Grant Fritchey (9/25/2009)


    Usually, delete the data in the referring tables first. Alternatively you could set up your foreign key constraints with cascading deletes. This is considered a dangerous approach, so...

Viewing 15 posts - 76 through 90 (of 101 total)