I want to write a Stored procedure...which will create a table 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 ---My sql
+2
A:
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//
Lukáš Lalinský
2009-10-10 08:01:29
I am new to dynamic table creation....it is throwing syntax error near '..)' when i am calling this procedure
hrishi
2009-10-10 08:10:40
Of course, you are supposed to replace *...* with your table definition. :)
Lukáš Lalinský
2009-10-10 08:12:35
off course its working fine ..but not for varchar typa like 'mh-30-o-126'
hrishi
2009-10-10 09:51:47