DECLARE @SENSORName as NVARCHAR; DECLARE @SENSORNUm as INT; DECLARE @TEMP as SMALLINT; DECLARE @Day as TINYINT; DECLARE @Hour as TINYINT; DECLARE @MinTemp as SMALLINT; DECLARE @MaxTemp as SMALLINT; SET @SENSORNum = 0; SET @Day = 1; SET @Hour = 1; SET @MinTemp = -80; SET @MaxTemp = 135; SET @TEMP = @MinTemp; SET @SENSORName = (SELECT MIN([SENSOR_ID]) from SENSOR where @SENSORNum < ID) WHILE @SENSORName is not null BEGIN INSERT INTO [Hourly]([SENSOR],[TEMP],[Day],[Hour]) VALUES(@SENSORName, @TEMP, @Day, @Hour) SET @Hour = CASE WHEN @Hour = 24 THEN @Hour = 1 SET @Day = CASE( WHEN @Day = 7 THEN SET @Day = 1 ELSE SET @Day = @day + 1 ELSE SET @Hour = @Hour + 1 END;
|What should be a storage size for SQL in day1, day2 and day 3||7||82|
|Excel conversion issue with Sql server||14||50|
|SQL Error in WHERE Clause||5||42|
|How to base a filter depending on fields contents?||15||49|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
16 Experts available now in Live!