@x赋值要用select or set;
没必要exec(@x)

解决方案 »

  1.   

    你的语句让@x等于什么呢?
    用以下语句吧 
    select @x=a.date1,b.ee from asd a,sds b where a.edf = @a  
      

  2.   

     对不起,理解错误。
    直接
    select a.*,b.ee from asd a,sds b where a.edf = @a
    即可 
      

  3.   

    可以这样写!
    declare @a varchar(20)
    declare @x varchar(2000)select @x="select a.*,b.ee from asd a,sds b where a.edf =convert(datetime,'"+ @a+"')"  
    exec (@x)
     其实sql server数据库字符串和时间类型不分!你可以用字符串查下面两个sql 语法的功能是一样的
    1。declare @sql varchar(500),@today varchar(20)
    select @today='2000/01/01'
    select @sql="select * from base01 where contentdate='"+@today+"'"exec(@sql)
    2。
    declare @sql varchar(500),@today varchar(20)
    select @today='2000/01/01'
    select @sql="select * from base01 where contentdate=convert(datetime,'"+@today+"')"exec(@sql)