I have this table, with site id, visitstartdate and visitenddate
I am trying to get the sequence of visit, and wrote this query
DECLARE @TBL TABLE (ID INT, VSTARTDATE DATETIME, VENDDATE DATETIME)
INSERT INTO @TBL
SELECT 1, '01/01/2007', '01/10/2007'
UNION ALL SELECT 1, '01/03/2007'...