declare @sql varchar(8000)
select @sql='select p.BillNumberID,p.BillCode,p.BtypeID,CompanyFullName=(select FullName from Btype where typeID=p.BtypeID ),p.ARTotal,p.LimitDate
from [otherAR] p
where BillDate<='''+CONVERT(varchar(10),@chvEnddate,120)+'''
union all
select p.BillNumberID,p.InvoiceCode,p.BtypeID,p.CompanyFullName=(select FullName from Btype where typeID=p.BtypeID ),p.TotalTotal,p.LimitDate
from [InvoiceIndex] p
where BillDate<='''+CONVERT(varchar(10), @chvEnddate,120)+''''exec(@sql)
select @sql='select p.BillNumberID,p.BillCode,p.BtypeID,CompanyFullName=(select FullName from Btype where typeID=p.BtypeID ),p.ARTotal,p.LimitDate
from [otherAR] p
where BillDate<='''+CONVERT(varchar(10),@chvEnddate,120)+'''
union all
select p.BillNumberID,p.InvoiceCode,p.BtypeID,p.CompanyFullName=(select FullName from Btype where typeID=p.BtypeID ),p.TotalTotal,p.LimitDate
from [InvoiceIndex] p
where BillDate<='''+CONVERT(varchar(10), @chvEnddate,120)+''''exec(@sql)
解决方案 »
- sqlserver2005下建立用户时,怎样能建立一个密码简单的用户?
- 大问题!!!怎样查看作业调度
- 请教想用循环建表字段,但不知道为什么加字段语句不能用变量?附代码
- 加法算法求助
- 我的sqlserver 2000(sp4)为什么总是占用很大的内存?
- 数据库字符串操作问题?
- 在线求救!关于还原问题!
- SQL Server 2005 数据误删除,无备份,日志还原求教
- 亲爱的ACCESS这是为什么?
- 请教有关'的问题,特急!!
- 那为高手能讲解一下 sql sever 2000中 UNIQUE的作用请举例~!
- 〓〓>===→ 欢迎大家来讨论,物料清单的问题。 好的回复单独开贴给分,每位50~100分
不行,我试了报错啊:服务器: 消息 170,级别 15,状态 1,行 5
第 5 行: '=' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 5
第 5 行: ',' 附近有语法错误。
set @chvEndDate='2001-02-03'
select @sql='select p.BillNumberID,p.BillCode,p.BtypeID,CompanyFullName=
(select FullName from Btype where typeID=p.BtypeID ),p.ARTotal,p.LimitDate
from [otherAR] p where BillDate<='''+@chvEnddate+''''
exec(@sql)
select @sql='select p.BillNumberID,p.BillCode,p.BtypeID,CompanyFullName=(select FullName from Btype where typeID=p.BtypeID ),p.ARTotal,p.LimitDate
from [otherAR] p
where BillDate<='''+@chvEnddate+'''
union all
select p.BillNumberID,p.InvoiceCode,p.BtypeID,p.CompanyFullName=(select FullName from Btype where typeID=p.BtypeID ),p.TotalTotal,p.LimitDate
from [InvoiceIndex] p
where BillDate<='''+@chvEnddate+''''
from [otherAR] p where BillDate<='''+CONVERT(varchar(10),@chvEnddate,120)+''' union all select p.BillNumberID,p.InvoiceCode,p.BtypeID,(select FullName from Btype where typeID=p.BtypeID ),p.TotalTotal,p.LimitDate
from [InvoiceIndex] p where BillDate<='''+CONVERT(varchar(10), @chvEnddate,120)+''''