如果你是用MSSQL
可以用execute("select * from "+@tablename+" where "+@condition)

解决方案 »

  1.   

    如果你使用的是MS SQL Server
    Create procedure SP (@TableName varchar(20))
    As
    declare @Temp varchar(10)--->因为通过Exec运行过的数据表这里定义的变量是不能用的,所以最好的方式是把表名作为参数传递的数据表存为一个全局临时表,这样可以操作这个临时表。
    begin
      exec('select * into ##Table from ' + @TableName)
      select * from ##Table
    end;good luck三少 :o)
      

  2.   

    oracle
    execute immediate 'select * from '||name;
      

  3.   

    谢谢各位的回答,但我是在SYBASE下写存储过程,请各位高手再次指教!