January 16, 2013 at 1:19 pm
i have a table in which i have two coulmns of StartDate and EndDate.
i want to create an another table in which i have date coulmn. and i want to select all the range between these dates in that Date coulmn.
how would this be implemented. Additionally i am using SQL Server 2008 and i am working in Visual studio 2010.
January 16, 2013 at 1:34 pm
It depends on the exact results you want.
One way to do that is to join the two tables:
select *
from dbo.MyTable1 as T1
inner join dbo.MyTable2 as T2
on T2.DateColumn between T1.DateColumn1 and T1.DateColumn2;
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
January 17, 2013 at 10:21 am
thanks for your rply
after excuting this query i got all the table of T1.
Actually i have two table T1.
in T1 i have two coulmns StartData and EndDate.
i want the date range selected between StartData and EndDate is to available in Date coulmn in another table.
As there are many rows in T1 so each row has to have its own StartData and EndDate. So for each row i want different table to be created. As there any way to implement it.
thanks in advance.
January 17, 2013 at 9:50 pm
Hi,
If you can explain it a bit more with expected data it would be really helpful to answer your question ..
Thanks,
Chinna
Its the Journey which gives you Happiness not the Destination-- Dan Millman
January 18, 2013 at 7:35 am
Seems the OP started a new thread for this. http://www.sqlservercentral.com/Forums/Topic1408582-391-1.aspx
I provided a solution in that thread.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 18, 2013 at 9:48 am
thanks for your rply.
Actually i am working in visual studion 2010 and SQL Express server 2008. i created my database through SQL Express server 2008.
Now i have i have a table in which i have three coulmns.
StartDate EndDate Class
and i have an another table name as "DateTabe" which has also three coulmns
Date Class Time
i want that the date selected between StartDate and EndDate is made available in 'Date' coulmn which is in DateTable with class in 'class' coulmn.
StartDateEndDateclass
10/1/1213/1/12 A
14/1/1217/1/12 B
Then these can be show as in DateTable as
Date class Time
10/1/12 A
11/1/12 A
12/1/12 A
13/1/12 A
14/1/12 B
15/1/12 B
16/1/12 B
17/1/12 B
Please explain in such way so that i can implement it in visual studio 2010.
Thanks in advance
January 18, 2013 at 10:01 am
armaandani (1/18/2013)
thanks for your rply.Actually i am working in visual studion 2010 and SQL Express server 2008. i created my database through SQL Express server 2008.
Now i have i have a table in which i have three coulmns.
StartDate EndDate Class
and i have an another table name as "DateTabe" which has also three coulmns
Date Class Time
i want that the date selected between StartDate and EndDate is made available in 'Date' coulmn which is in DateTable with class in 'class' coulmn.
StartDateEndDateclass
10/1/1213/1/12 A
14/1/1217/1/12 B
Then these can be show as in DateTable as
Date class Time
10/1/12 A
11/1/12 A
12/1/12 A
13/1/12 A
14/1/12 B
15/1/12 B
16/1/12 B
17/1/12 B
Please explain in such way so that i can implement it in visual studio 2010.
Thanks in advance
Try reading the response I posted in your other thread. You really need to stick with a single thread.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply