Welcome to Sign in | Help

Re: trigger conditionat

  •  12-14-2008, 6:52 PM

    Re: trigger conditionat

    [1] adaugi în tabela (presupunând că e doar o tabelă) pe care o interoghezi, denumită în continuare TabelaPeştelui,
    ... where created between getdate()- 1 and getdate() ...
    un câmp ID INT IDENTITY(1,1)

    [2] creezi o tabelă auxiliară
    CREATE TABLE TabelaID (ID INT NOT NULL)

    [3] În declanşator adaugi următoarele comenzi T-SQL
    ...
    DECLARE @last_id INT
    DECLARE @max_id INT

    SET @last_id =  ISNULL( (SELECT MAX(ID) FROM TabelaID) , 0 )
    SET @max_id = ISNULL( (SELECY MAX(ID) FROM TabelaPeştelui) , 0 )

    ... from TabelaPeştelui
        where (ID BETWEEN @last_id+1 AND @max_id)
              AND created between getdate()- 1 and getdate() ...

    ...


    INSERT INTO TabelaID VALUES ( @max_id )
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems