日期:2014-05-18 浏览次数:20611 次
EXEC (' SELECT vvm.*, dbo.GetBidPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR)+''','''+CAST(@EndDateTime AS VARCHAR)+''') AS BidPublishNum, dbo.BuyerPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR)+''','''+CAST(@EndDateTime AS VARCHAR)+''') AS BuyerPublishNum, dbo.AttentionPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR)+''','''+CAST(@EndDateTime AS VARCHAR)+''') AS AttentionPublishNum, TradeOrder.TradeAmount, TradeOrder.Sevice_Pay, TradeOrder.Sevice_NotPay, TradeOrder.LogisticsFee, TradeOrder.TransferFee, dbo.GetTradeSuccessPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR)+''','''+CAST(@EndDateTime AS VARCHAR)+''') AS TradeSuccessPublishNum, dbo.GetAppealPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR)+''','''+CAST(@EndDateTime AS VARCHAR)+''') AS AppealedPublishNum FROM V_VendorManager vvm LEFT JOIN (SELECT * FROM dbo.GetVendorTradeData('''+CAST(@StartDateTime AS VARCHAR)+''','''+CAST(@EndDateTime AS VARCHAR)+''')) AS TradeOrder ON vvm.TvaID=TradeOrder.BuyerTvaId ')
declare @StartDatetime datetime declare @EndDateTime datetime declare @sql varchar(max) set @sql=' SELECT vvm.*, dbo.GetBidPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR(20))+''','''+CAST(@EndDateTime AS VARCHAR(20))+''') AS BidPublishNum, dbo.BuyerPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR(20))+''','''+CAST(@EndDateTime AS VARCHAR(20))+''') AS BuyerPublishNum, dbo.AttentionPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR(20))+''','''+CAST(@EndDateTime AS VARCHAR(20))+''') AS AttentionPublishNum, TradeOrder.TradeAmount, TradeOrder.Sevice_Pay, TradeOrder.Sevice_NotPay, TradeOrder.LogisticsFee, TradeOrder.TransferFee, dbo.GetTradeSuccessPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR(20))+''','''+CAST(@EndDateTime AS VARCHAR(20))+''') AS TradeSuccessPublishNum, dbo.GetAppealPublish(vvm.TvaID,'''+CAST(@StartDateTime AS VARCHAR(20))+''','''+CAST(@EndDateTime AS VARCHAR(20))+''') AS AppealedPublishNum FROM V_VendorManager vvm LEFT JOIN (SELECT * FROM dbo.GetVendorTradeData('''+CAST(@StartDateTime AS VARCHAR(20))+''','''+CAST(@EndDateTime AS VARCHAR(20))+''')) AS TradeOrder ON vvm.TvaID=TradeOrder.BuyerTvaId ' exec (@sql)
------解决方案--------------------
declare @StartDatetime datetime set @StartDatetime=getdate() select convert(varchar(10),@StartDateTime,120) /* 2012-06-05 */ --1\转时间格式建议使用convert --2\在外面拼接后,统一exec