Here is my procedure statment. DELIMITER $$
DROP PROCEDURE IF EXISTS `david_test`.`sp_test_prepare`$$ CREATE PROCEDURE `david_test`.`sp_test_prepare`(IN f_top int) BEGIN set @sqltext = concat('select * from test limit ',f_top); prepare s1 from @sqltext; execute s1; drop prepare s1; END$$ DELIMITER ; But this procedure needs many memory to allocate result query. So I want to change it to the following statment. DELIMITER $$ DROP PROCEDURE IF EXISTS `david_test`.`sp_test_prepare`$$ CREATE PROCEDURE `david_test`.`sp_test_prepare`(IN f_top int) BEGIN declare sqltext varchar(1000); set sqltext = concat('select * from test limit ',f_top); prepare s1 from sqltext; execute s1; drop prepare s1; END$$ DELIMITER ; But this is not correct. Maybe prepare statment only supports dynamic variables,but does not support static variables. Could anybody give me an advice? -- I'm a mysql DBA in china. More about me just visit here: http://yueliangdao0608.cublog.cn