我在数据库有个字段的值用来代表其他表的某字段,那我要怎么查询这个字段的值呢?
我试过如下方法:
exec('select @temp='+@ID+' from product')
不过就出现@temp未声明的错误,不过我已经声明了.EXEC没有结果返回值吗?

解决方案 »

  1.   

    string strSql =  "select  "+字段变量+ " from product";
      

  2.   

    exec('select '+@temp+'='+@ID+' from product')
    试试
      

  3.   

    漏了说明,我想在存储过程中编写,所以不在ASP.NET下.
      

  4.   

    如果直接是SQL的话就可以象一般的变量来做,但是如果是存储过程就不行了。
      

  5.   

    再('select @temp='+@ID+' from product')的select前声明temp