-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE TABLE tdt (
    id INTEGER PRIMARY KEY,
    val DECIMAL(10,2),
    dt DATETIME
)
GO

INSERT INTO tdt VALUES(1, 123.45, CAST('2005-10-23' AS DATETIME))
GO
INSERT INTO tdt VALUES(2, 678.90, CAST('2005-10-25' AS DATETIME))
GO

SELECT * FROM tdt
GO

CREATE PROCEDURE uspdt(@startDate AS datetime,@endDate AS datetime)
AS
SELECT SUM(val) AS sumval FROM tdt WHERE dt BETWEEN @startDate AND @endDate
GO
