一聚教程网:一个值得你收藏的教程网站

热门教程

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

时间:2022-06-30 10:21:17 编辑:袖梨 来源:一聚教程网

/* -----------------------------------
    产生论坛分类目录内容表过程
     -----------------------------------    */
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 ,        

热门栏目