Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi All,I want to return a result set containing 4 static column and after that collumns name with name like 1 Jan 2012 to number of days in month. ex. A B C D 1 Jan 2012 1 Jan 2012 2 Jan 2012 .... 31 Jan 2012Number of Columns vary with number of days in month.Please suggest a good solution for this query.I can also Hide colum at my front end if query will return 35 rows(4+max number of days in month) every time and number of days is less than 31 in that month.Please help.Thanks in advance..Anuj Pratap Singh
Yes. absolutely !KH[spoiler]Time is always against us[/spoiler]
anujpratap84
Starting Member
45 Posts
Posted - 2012-01-16 : 06:34:57
Thanks 4 reply..but how i use this in my query to show result under the date header..Can you please provide a sample example..Like if i have 2 tables where all required data stored i'll apply join between those two tables and get data but how i use this funtion in that query..Thanks for your support...
SELECT f.[Date],... other fieldsFROM dbo.CalendarTable(@yourstartdate,@yourenddate,0,0)fLEFT JOIN yourtable tON t.datefield = f.[Date]...
@yourstartdate and @yourenddate are varibles through which you pass start and end values------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/