存储中变量怎么写?
存储过程中
定义了2个变量
@BegDate
@EndDate
@SQL
我想如果这个两个变量为空则查询所有的记录
SET @SQL ='1=1'
IF (@BegDate<>''AND @EndDate<>'')
SET @SQL=@SQL+' and AccDate between '+@BegDate+' and ' + @EndDate
如:select WarehouseID,AccDate,SUM(SaleAmt) AS Saleamt from #T where AccDate between @BegDate and @EndDate group BY WarehouseID,AccDate
select WarehouseID,AccDate,SUM(SaleAmt) AS Saleamt from #T where +@sql group BY WarehouseID,AccDate
这样要报错的 请问一下这个语句怎么写呢?
广告时间