在asp中如何创建动态表--调用如下sp_executesql

作者:网络 来源:佚名 更新时间:2008-02-05 15:17:23 点击:
|||
p; exec sp_executesql @st
    
    select @st='create trigger '+ @tri_inst_name+' on '[email protected]+ '
        for insert
    as
        declare @rid integer,@pid integer
        select @pid=parentid from inserted
        if @pid = 0
            begin
            select @rid [email protected]@identity
            update '+ @tabname+' set [email protected] where [email protected]
            end'
    exec sp_executesql @st

    select @st='create trigger '+ @tri_up_name+' on '[email protected]+ '
        for update
    as

        declare @pid int ,@rid int,@forbid tinyint
        if update(forbid)
              begin
            select @pid = parentid,@rid = rootid,@forbid=forbid from inserted
            /* 如果其父没有开放 则不能开放 */
            if exists ( select * from  '[email protected] +' where announceid = @pid and forbid!= 0 )
                   begin
                rollback transaction
                return
                    end
            update '[email protected]+ ' set [email protected] where [email protected] and parentid>@pid
                end'
        exec sp_executesql @st
    
    select @st='create trigger '+ @tri_del_name+' on '[email protected]+ '
        for delete
    as
        declare @pid int ,@rid int
        select @pid = parentid,@rid = rootid from deleted
        delete from '[email protected] +' where [email protected] and parentid>@pid'

        exec sp_executesql @st