sql发邮件@query字符串拼接

来源:百度知道 编辑:UC知道 时间:2024/06/04 22:36:11
sql 发邮件 @query怎么写字符串连接
@query =‘ select * from a where orderTime> Convert(varchar(10),getdate()- DAY(getdate()) + 1,23)+' 00:00:00'
’ 查询本月大于第一天的数据
显然我这条sql语句是错误的 语句始末端有两个引号。而我连接‘ 00:00:00’的时候也有两个引号。。。。

set @query =' select * from b where [数据]> (select [数据] from a where convert(varchar(10),orderTime,120)=convert(varchar(7),orderTime,120)+'+char(ascII('+'))+char(39)+01+char(39)+')'

select @query = select * from a where orderTime> left( Convert(varchar(10),getdate(),120),7) + '-01 00:00:00'