选择显示字体大小

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


  /* -----------------------------------
    产生论坛分类目录内容表过程

   -----------------------------------    */
create procedure sp_createnew_bbscontent
    @tabname varchar(200)='',
    @boardid int
as
    declare @tri_inst_name nvarchar(100)
    declare @tri_up_name nvarchar(100)
    declare @tri_del_name nvarchar(100)
    declare @deltab nvarchar(100)
    declare @st nvarchar(2000)
    select @tri_inst_name='inst_bbscontent'+ltrim(rtrim(str(@boardid)))
    select @tri_up_name='up_bbscontent'+ltrim(rtrim(str(@boardid)))
    select @tri_del_name='delete_bbscontent'+ltrim(rtrim(str(@boardid)))
    select @deltab='drop table '+@tabname
    if len(@tabname)=0
        return
    if exists (select * from sysobjects where id = object_id(@tabname) and objectproperty(id, n'isusertable') = 1)
        exec sp_executesql @deltab

    select @st='create table '+@tabname+
        '(
        announceid    int    identity (1, 1)     not null ,    
        parentid     int    default (0)        null ,        
        child         int     default (0)        null ,        
        user_id         int                 null ,        
        boardid        int                null ,        
        topic         nvarchar (255)             null ,
        body         ntext                null ,
        dateandtime     datetime default    (getdate()) null ,
        hits         int    default (0)        null ,
        length        int    default (0)        null ,
        rootid         int    default (0)        null ,
        layer         tinyint    default (1)        null ,
        orders         int     default (0)        null ,
        ip         nvarchar (20) default (0)    null ,
        expression     nvarchar (50)             null ,
        forbid         tinyint default(0)        null
        )'
    exec sp_executesql @st
    
    select @st='create trigger '+ @tri_inst_name+' on '+@tabname+ '
        for insert
    as
        declare @rid integer,@pid integer
        select @pid=parentid from inserted
        if @pid = 0
            begin
            select @rid =@@identity
            update '+ @tabname+' set rootid=@rid where announceid=@rid
            end'
    exec sp_executesql @st

    select @st='create trigger '+ @tri_up_name+' on '+@tabname+ '
        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  '+@tabname +' where announceid = @pid and forbid!= 0 )
                   begin
                rollback transaction
                return
                    end
            update '+@tabname+ ' set forbid=@forbid where rootid=@rid and parentid>@pid
                end'
        exec sp_executesql @st
    
    select @st='create trigger '+ @tri_del_name+' on '+@tabname+ '
        for delete
    as
        declare @pid int ,@rid int
        select @pid = parentid,@rid = rootid from deleted
        delete from '+@tabname +' where rootid=@rid and parentid>@pid'


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons