Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-11-05 : 07:33:58
|
| [code]DateFrom DateTo1/1/2008 1/1/20087/2/2008 10/2/2008[/code]Is it possible to output all the dates from this table, for example this should output1/1/20087/2/20088/2/20089/2/200810/2/2008Can I do that with SQL?Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-05 : 07:40:10
|
yes. use CROSS APPLY your table to F_TABLE_DATE KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-05 : 07:42:19
|
Yes, with the new CROSS APPLY function you can. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-11-05 : 08:04:21
|
| Hi,Thanks for this. I have no experience with functions, i've managed to *install* the f_table_date function onto my database.How do I call the function and apply to to my own table?Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-05 : 08:07:47
|
[code]DECLARE @Sample TABLE (DateFrom DATETIME, DateTo DATETIME)SET DATEFORMAT DMYINSERT @SampleSELECT '1/1/2008', '1/1/2008' UNION ALLSELECT '7/2/2008', '10/2/2008'SELECT d.DATEFROM @SampleCROSS APPLY F_TABLE_DATE(DateFrom, DateTo) AS d[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-05 : 08:08:20
|
[code]DECLARE @sample TABLE( DateFrom datetime, DateTo datetime)SET dateformat dmyINSERT INTO @sample (DateFrom, DateTo)SELECT '1/1/2008', '1/1/2008' UNION ALLSELECT '7/2/2008', '10/2/2008'SELECT d.DATEFROM @sample s CROSS apply F_TABLE_DATE(DateFrom, DateTo) dORDER BY d.DATE/*DATE ------------------------------------------------------ 2008-01-01 00:00:00.0002008-02-07 00:00:00.0002008-02-08 00:00:00.0002008-02-09 00:00:00.0002008-02-10 00:00:00.000(5 row(s) affected)*/[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-11-05 : 08:15:22
|
| THANKS !! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-05 : 08:22:38
|
read about CROSS APPLY in BOL KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|