@x赋值要用select or set;
没必要exec(@x)
没必要exec(@x)
解决方案 »
- 求数量和,谢谢
- 请问这个模糊查询的语句语法对吗?
- 求对象名无效问题
- 请问这样的SQL语句应该如何写
- 控制字段长度(因为没有分了,所以。。。)
- reporting services报表管理器上载文件失败
- 有难度的SQL,高手请进,速度结帖!
- 如何用SQL语句取得数据库sql2005中的所有数据表中每一个字段的描述信息呢?(高手请进入!!)
- 在pb7开发环境中怎样连接sql server2000?
- [求助]MSSQL如何实现全实时同步
- 对于SQL Server 6.5的数据库文件*.dat,怎样在SQL Server 7.0中转换成新的DATABASE?
- 合并数据结果集的SQL语法是什么!分必给!!!
用以下语句吧
select @x=a.date1,b.ee from asd a,sds b where a.edf = @a
直接
select a.*,b.ee from asd a,sds b where a.edf = @a
即可
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)