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

作者:袖梨 2022-06-30
/* -----------------------------------
    产生论坛分类目录内容表过程
     -----------------------------------    */
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 ,        

相关文章

精彩推荐