You can use the EXEC () function to dynamically Execute SQL statements in MSSQL. MSSQL also has a similar function EXECUTE (), but the difference is that the dynamic execution of stored procedure statements in MYSQL is different from that in MSSQL.
You can use the EXEC () function to dynamically Execute SQL statements in MSSQL. MSSQL also has a similar function EXECUTE (), but the difference is that the dynamic execution of stored procedure statements in MYSQL is different from that in MSSQL.
Here is a reference for everyone.
The Code is as follows:
Create procedure sp_find (pfind varchar (500)
BEGIN
DECLAR msql varchar (2000 );
SET @ MyQuery = Concat ('select * from Table where', pfind );
PREPARE msql from @ MyQuery;
EXECUTE msql;
END
Note that many defined functions can be used in MYSQL, such as the concatenation function Concat () above. It is helpful to make good use of these functions.