我希望从这个查询中获取 ExtratedDate 的值,并在下一个查询中将其作为@LastExtratDate 使用。 我该怎么做?
SELECT TOP 1 [ExtractedDate]
FROM [OnsiteV4].[dbo].[SqlPendingIndex] order by ExtractedDate desc
下一个问题:
insert into @table(Hex, KeyDeviceId, ObjectDateTime, ExtractedDate )
SELECT CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), ObjectValue, 1)) AS Hex, KeyDeviceId, ObjectDateTime , GETDATE ()
FROM SQLPending
WHERE (ObjectSubType LIKE '%GAS%') and (ObjectDateTime > @LastExtractDate)