USE [db_iwfs]
GO
/****** Object: StoredProcedure [dbo].[UpateDataInHourFac] Script Date: 2021/7/29 8:26:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,更新192.168.2.23 dbo.DataInHourFac,>
-- =============================================
ALTER PROCEDURE [dbo].[UpateDataInHourFac]
AS
BEGIN
declare @year varchar(4) --年
declare @day varchar(10) --日
declare @hour int --小时
set @year=DATEPART(yyyy,GETDATE())
set @day=CONVERT(varchar(100), GETDATE(), 23)
set @hour=DATEPART(hh,GETDATE())
declare @record varchar(20)
declare @sql nvarchar(500)
declare @val varchar(500)
set @record='tb_point_record'
set @record=@record+'_'+@year
set @sql= N'select top 1 @val= value from '+@record+' where pointcode=''YQZK_DCJRLJ'' and DATEDIFF(HH,datetime,GETDATE() ) =0 '
--print @sql
exec sp_executesql @sql,N'@val varchar(500) output',@val output
update [链接服务器].[DB_PLDS].[dbo].[DataInHourFac] set iPressureData=@val where CONVERT(varchar(100), ddatadate, 23)=@day and ihour=@hour and cRemark='东出厂水流量'
END