USE [CablewayMonitorPlatform]
GO
/****** Object: StoredProcedure [dbo].[SelectPortableHistoryResult] Script Date: 06/12/2019 21:24:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[SelectPortableHistoryResult]
@OId varchar(20),
@Time varchar(50)
AS
BEGIN
SET NOCOUNT ON;
declare @sqlcommand nvarchar(MAX)=N''
set @sqlcommand='select * from t_PortableResult where 1=1 '
if(@OId is not null)
set @sqlcommand=@sqlcommand+' and OId=' +cast(@OId as varchar)
if(@Time is not null)
begin
set @sqlcommand=@sqlcommand+' and Time<= '''+@Time+'''' + ' and DATEADD(dd,7,Time)> '''+ @Time+''''
end
print(@sqlcommand)
exec(@sqlcommand)
END
查询七天内(前后七天):
USE [CablewayMonitorPlatform]
GO
/****** Object: StoredProcedure [dbo].[SelectPortableHistoryResult] Script Date: 06/12/2019 21:46:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[SelectPortableHistoryResult]
@OId varchar(20),
@Time varchar(50)
AS
BEGIN
SET NOCOUNT ON;
declare @sqlcommand nvarchar(MAX)=N''
set @sqlcommand='select * from t_PortableResult where 1=1 '
if(@OId is not null)
set @sqlcommand=@sqlcommand+' and OId=' +cast(@OId as varchar)
if(@Time is not null)
begin
set @sqlcommand=@sqlcommand+' and DateDiff(dd,Time,cast('''+@Time+''' as varchar))<=7 '
end
print(@sqlcommand)
exec(@sqlcommand)
END