开发者

How to change name of table while creating it through Stored procedure

开发者 https://www.devze.com 2022-12-08 18:21 出处:网络
I want to write a Stored procedure...which will create a ta开发者_JS百科ble with xyz name ...but when i call the SP for very second time it will give the error bcoz table already exist...I want to tak

I want to write a Stored procedure...which will create a ta开发者_JS百科ble with xyz name ...but when i call the SP for very second time it will give the error bcoz table already exist...I want to take table name as input..and want table to be created with that name... How to archive this..... Asp.net ---Mysql


delimiter //
CREATE PROCEDURE CreateTable (IN name VARCHAR(100))
BEGIN
  SET @q = CONCAT('CREATE TABLE ', name ,' (...)');
  PREPARE s FROM @q;
  EXECUTE s;
  DEALLOCATE PREPARE s;
END//
0

精彩评论

暂无评论...
验证码 换一张
取 消