0

I have a Table with the following Fields:

----------------------------------------
| Start Date        | Recurrences      |
----------------------------------------
| 01-01-2015        | 12               |
----------------------------------------
| 01-06-2015        | 10               |
----------------------------------------

What I need to output is a total of 22 rows (12 + 10). Each row should contain the 'Start Date' field plus the increment of days depending on which recurrence.

I was able to generate a number of rows with an increment using this table of SQL Server:

SELECT 
    DISTINCT n = number 
FROM 
    master..[spt_values] 
WHERE 
    number BETWEEN 1 AND 1000

But what I need is to trigger this select per each row of my table and set the MAX to Recurrences field and not to 1000

1 Answer 1

2

Since you're multiplying, a simple inner join should do:

select
 Number,
 StartDate
from YourTable
inner join master..[spt_values] on number between 1 and YourTable.Recurrences
Sign up to request clarification or add additional context in comments.

1 Comment

So easy ... I think I need more coffe. Thanks work perfect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.