日期:2012-07-03  浏览次数:20817 次

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

   -----------------------------------    */
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)