declare @schemaname varchar(128)
declare @tablename varchar(128)
-- now, grab the table name that goes with our id
select @schemaname
schemaname = schemaname,
@tablename
tablename = tablename
from dynamicsqlexample
where tableid = 15
-- finally, pass that value into the exec statement
exec ('select * from ' + @schemaname + '.' + @tablename)
mysql 動態執行SQL文
參考 mysql 儲存過程中動態執行 sql 文 2 pow mysql prepa re stmt1 from select sqrt pow 2 as hypotenuse mysql set a 3 mysql set b 4 b class userinputexecute stmt1 us...
mysql 動態執行SQL文
在mysql儲存過程中動態執行sql文 mysql prepare stmt1 from select sqrt pow 2 pow 2 as hypotenuse mysql set a 3 mysql set b 4 mysql execute stmt1 using a,b mysql set...
ORACLE 動態執行SQL語句
oracle 動態sql oracle 動態sql有兩種寫法 用 dbms sql 或 execute immediate,建議使用後者。試驗步驟如下 1.ddl 和 dml ddl begin execute immediate drop table temp 1 execute immediat...