Welcome to Sign in | Help

Re: DROP constrangere (SQL 2000 si SQL 2005)

  •  02-19-2008, 11:23 AM

    Re: DROP constrangere (SQL 2000 si SQL 2005)

    cretzu:
    Okay,

    Am inteles, se pot redenumi constrangerile iar acestea sunt in sysobjects si cu xtype  pe 'PK' si 'F'.
    Dar cum pot sa fac cat m optim redenumirea constrangerilor.

    Pot sa scot intr-un select name from sysobjects cu constrangerile si cu conditia ca numele sa contina cifre.
    Dar ca sa fac rename pe fiecare in parte dintre aceste contrangeri nu stiu alta posibilitate decat sa folosesc un cursor si pentru fiecare element sa ii fac rename.



    Nu stiu f bine cum se scot constrangerile din BD ( cu xtype  pe 'PK' si 'F'.)
    dar poti face un update de genul
    update <sysobjects> set <nume_fk> = 'fk' + '<nume_tabela_pk>' + '<nume_tabela_fk>'
    from <sysobjects> inner join <systables> PK
    on <conditie de Primary table pe constringere>
    inner join <systables> FK
    on <conditie de Primary table pe constringere>

    where <sysobjects>.<este_constringere>( xtype  pe 'PK' si 'F', cum scrii tu)

    ( ma rog, mai intii ar trebui sa faci un select ... ca sa nu strici ceva...)


    Ignat Andrei
    http://serviciipeweb.ro/iafblog
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems