I am declaring a table variable as below.
declare @TableVar table ( interval Time not null)
I need to insert values as time starting from '8:00 am' to '8:00 pm' with an interval, of say 30 min, into this table variable.
I need the table variable with data as below
8:00 am
8:30 am
9:00 am
.
.
.
12:00 pm
12.30 pm
.
.
7:00 pm
7:30 pm
8:00 pm
This time interval of 30 min is derived from a field DMCDur(int) from a table.
DECLARE @intFlag INT
SET @intFlag = (select D.DMCDur from doctor_master D where D.doc_id=3)
Basically, I need to query a table to get the column DMCDur which can be: 30, 20, 15, etc. Representing: 30 min, 20 min, 15 min, respectively.
I need to set the start time as 8:00 am and need to add DMCDur with this start time and generate a set of time with interval as DMCDur and insert these values into the table variable I mentioned above.
My final aim is to join this set of time with another table data and populate a grid. So thought of going in this way.
Please suggest your ideas on this.Sample stored procedure for the same will be appreciated.
Note:Joining variable in the other table is a DATETIME variable(eg 2012-08-06 08:00:00.000).So the table variable should also be DATETIME as datatype so then I can join both tables with this time.