How to create a dynamic table in ASP-call the following SP

Source: Internet
Author: User
Tags rtrim
Create | dynamic/*-----------------------------------
Generate Forum Catalog Content table process

-----------------------------------    */
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 (+) default (0) NULL,
Expression nvarchar (m) NULL,
Forbid tinyint default (0) NULL
)'
&nbs



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.