Hello all,
I moving to another area of the comany I work in and I am learning SQL by being set challenges by my new manager.
The request in this case was to return a list of dates from today, 14 days into the future.
I have got this far,
USE [kdemo]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DAYDATELIST]
@date datetime, @days int
AS
BEGIN
SET NOCOUNT ON
DECLARE @anchordate DATETIME, @date2 datetime
SET @date2 = @date
SET @anchordate = @date2 + @days
CREATE TABLE #DATELIST (DTM DATETIME)
WHILE @date2 < @anchordate
BEGIN
INSERT INTO #DATELIST (DTM) VALUES (@date)
SET @date2 = @date+1
END
END
but have an opne loop so the query never ends.
Any help would be greatly appreciated.
I moving to another area of the comany I work in and I am learning SQL by being set challenges by my new manager.
The request in this case was to return a list of dates from today, 14 days into the future.
I have got this far,
USE [kdemo]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DAYDATELIST]
@date datetime, @days int
AS
BEGIN
SET NOCOUNT ON
DECLARE @anchordate DATETIME, @date2 datetime
SET @date2 = @date
SET @anchordate = @date2 + @days
CREATE TABLE #DATELIST (DTM DATETIME)
WHILE @date2 < @anchordate
BEGIN
INSERT INTO #DATELIST (DTM) VALUES (@date)
SET @date2 = @date+1
END
END
but have an opne loop so the query never ends.
Any help would be greatly appreciated.