I want to do a table valued function that returns a date and a number present for that day from a given numbers table.
I already have a function that you provide with a start and finish date to get all the dates required (dbo.Dates(@start, @finish) , and the number table, which has the numbers that i need for each day.
The tables are as follows
Date |
Day (datetime)
Numbers |
number int
name varchar
The output I require is below.
Date | Number ------------------ 20120501 | 1 20120501 | 2 20120501 | 3 20120502 | 1 20120502 | 2 20120502 | 3 20120503 | 1 ....
If you need all numbers on all days, then use cross join:
You then just need to put the “create function” wrapper around this to get a table valued function.