.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Creating Table of consecutive dates

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :Sql Server

I'm trying to create a table with one field (SmallDate&Time)

I want this table to have consecutive dates beginning roughly 01/01/2008

through 12/31/2013.

I think I need a Stored procedure to do this but am not sure.

It may even be doable from an SQL Query.

Any help would be appreciated.









View Complete Post

More Related Resource Links

Cutting Edge: Creating a Multi-table DataGrid in ASP.NET


If you bind a multi-table DataSet to a DataGrid, only the first table is recognized. Here Dino Esposito writes a custom solution the the multi-table problem.

Dino Esposito

MSDN Magazine August 2003

Creating a table-valued function on a user defined type in SQL Server CLR

We would like to be able to create a table-valued function on a user defined type.  We would like the syntax in SQL to look like it works for the XML nodes function:   DECLARE @myXml XML = '<a><b>1</b><b>2</b><b>3</b></a>' ; SELECT  node.query('text()') FROM    @myXml.nodes('a/b') nodes (node) ;   In other words, in the FROM clause, we can access the "nodes" method of the xml variable and it returns a rowset. Thanks!

Help creating HTML table from dataTable when every nth dataTable row = 1 html table row... C#

Hello, Im trying to create an html table from data that is in a dataTable but Im having trouble coming up with the right logic. Every 3 rows in the dataTable needs to be 1 row in the html table.  Ive tried using foreach through the datatable with a modulus to determin every third dataTable row but i still run into snags because i am building the table using objects rather than using concatenated strings..(example TableRow tr = new TableRow  etc...). I cant add the cells to the rows when the row is only created in an if statement etc. Can someone post a good example in c# of how they would achieve this. The amount of data in the dataTable could change from time to time so the code cant rely on a pre determined size, unless you just need the total rows and columns, that can be dtermined when the dataTable is filled from the sqlDataReader. <table><tr><td>dataTable row 1 values</td><td>ataTable row 2 values</td><td>dataTable row 3 values</td></tr> <tr><td>dataTable row 4 values</td><td>dataTable row 5 values</td><td>dataTable row 6 values</td></tr>   Any help and example would be great. Ive been able to do similar tables in other apps but thats only when I use concatenated text strings to build the html table. Im trying to stay away from that this time

how to load dates in a table in a range

Hi i have a table DATEDESC with columns [FullDate] [DateName] [YearName] [MonthName] [DayOfTheWeek] [YearNumber] [MonthNumber] [WeekNumber] [DayNumber] SAMPLE DATA OUTPUT FULL_DATE DATE YEARNAME MONTH_NAME DAY_NAME YEAR MONTH_NUMBER WEEK_WITHIN_THE_MONTH WEEK_WITHIN_THE_YEAR DAY_NUMBER 2010-09-09 24:31.9 2010-09-09 NOT LEAP YEAR September Thursday 2010 9 2 37 9   I need to load a series of dates into this tale by giving a start and and end dates range. Lets say i need to load 10yrs of date's data into this column, i need to load all the dates into this table and get those respective column. The query i had to populate the sample data was with the current date. But i am not sure how to do this for a bunch of data when it is in a range. SELECT GETDATE() AS FULL_DATE, Convert(varchar(10), getdate(),110) as DATE_NAME, CASE (YEAR(GETDATE()))%4 WHEN 0 THEN 'LEAP YEAR'ELSE 'NOT LEAP YEAR' END AS [YEAR_NAME], DATENAME(MONTH,GETDATE()) AS [MONTH_NAME], DATENAME("DW",GETDATE()) AS [DAY_OF_THE_WEEK], DATENAME(YEAR,GETDATE()) AS [YEAR_NUMBER], MONTH(GETDATE()) AS MONTH_NUMBER, DATEPART(DAY,GETDATE() -1)/7+1 AS [WEEK_WITHIN_MONTH], DATENAME("WEEK",GETDATE()) AS [WEEK_WITHIN_YEAR], DAY(GETDATE()) AS  DAY_NUMBER So, could you please help me in build this query. Thank you.

Creating table with database data, ASP.net and C#

Hi!I just started with my first ASP.net page with C# and I want to create a dynamic table with information from my database. I have connected to the database to the page with datareader, so that is solved. The problem is making the table and import the data into the different rows and columns. I also want the possibility to edit and remove this information from the table. Its supposed to be a table with information about customers.I have no idea whats the best solution for this and I hope you guys got information or links that show how to do this?Regards,fh01

trouble getting dates right when importing Access table

I was given a bunch of data in Access and am putting it in SQL 2005 for an ASP.NET web app. Tryingto do a query to select only records where the current date is after the "postDate" field and on or before the "expireDate" field. WHERE (postDate <= CURRENT_TIMESTAMP) AND (expireDate >= CURRENT_TIMESTAMP) I'm getting no records returned even though there are some records that qualify. Tried using CURDATE() and NOW(), no difference. At this point I think it may be because the dates are not in the correct format. The columns were originally "Date/Time" format in Access and when I imported them into SQL using the DTSWizard, the datatype for those columns became "smalldatetime." Dates are in the format M/DD/YYYY HH:MM:SS. I'm guessing the query won't work because SQL is expecting YYYY-MM-DD. How do I fix this? Been spending a depressing amount of time running in circles with this.

Help in Building Fiscal Dates Table

hi Experts,  I'm trying to build fiscal periods table. I have Calendar Dates of year 2007  in 1 table and just start Dates of Fiscal weeks in another table, can any one suggest me about building Fiscal table containing entire year using the 2 tables.  thank you ....   

Creating a Form say grid sort of a interface where in data values will be extracted from the table 4


how dis can be done help please with simple button click and changing the values it can be done but how to move columns with data in graceful manner the way we have in calendar control... 

Can a table name impact generating the service client when creating Service Reference?


I have a new WCF service I'm writing under VS2010 and IIS 7.5.  The service includes a table named Client.

When I built my test class and added the service reference, the first test was confirming the creation of the client.

My service reference did not generate any client that I could call .Open on!!!! I was wondering if it is due to that table name???

 Edited to add that I tested the service through the browser and it brings up the page and XAML fine.

Thanks for any assistance!

Creating table records with foreign key constraints/Separate controllers?


I have multiple tables that are all linked back to a central table with foreign keys. I want to be able to create a new record in table 2, but I'm having trouble because I don't know how to create a new instance of table 2's record while referencing the ID of the record it will be tied to.


query wich returns records for each day between start date from table 1 and mutation dates in table



I have to tables with dates, table Employments with all employements of all employees, with start date and end date, and a table Mutations with mutations (e.g in salary) with start dates.

Now I try to write a query which returns a record for each day an employee is in employment, with the correct salary. SO at first, it should return all days between the employment start date and the first mutation date, then the number of days between the first mutation date and the second mutation date etcetc, and at last the number of days between the last mutation date and the employment end date. The number of mutations varies for each employment, and employees cna have multiple employments (history, so not at the same time) in the employments table.

How to do this?

creating custom table in share point database in sqlserver is fine ?


we are creating custom table in share point database in sqlserver.

is it fine to create custom table?

are we violating any rule  because of the creation of custom table ?

does share point recommended to create custom table  ?

Help needed with creating Pdf table out of list of dataSets


Hey there,

I'm trying to create a pdf table using data from a list of datasets.

Each dataset may contain 0 to 4 rows as follows, and the data within that dataset is specific to a particular month:


CommunicationType         CommunicationCount
email                                           20
letter                                           10
phone                                           5
fax                             &n

creating sql table from code c#


Hello i want that site manager will create his own tables in the Database in 2 steps!!! the first one is to create table in the database the user can choose the name of the new table by textbox and the table get only one ID column:

SqlConnection newCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            String st = "CREATE TABLE DataBaseConn.dbo." + tableName.Text.Trim()
                + "(contactId INTEGER PRIMARY KEY IDENTITY)";
            SqlCommand newCmd = new SqlCommand(st, newCon);

in the next step i want the user will add/insert the columns to the table (one column each time) the user will have textbox for the column name, drop down list with few kind of data type (datetime, int, varchar) and after press button the column will add to the table. ANY IDEA?????

Creating Table from DataSet


Hello all,

Real simple one here.  I'd like to create a table on my Page from a DataSet.  It looks like I have it working properly, but what I'd like to do is interpret the columns, as well as be selective with which column to display.

            Dim dc As DataColumn
            Dim dr As DataRow

            For Each dr In ds.Tables(0).Rows

                Dim trow As New TableRow

                For Each dc In ds.Tables(0).Columns

                    Dim tcell As New TableCell

                    tcell.Controls.Add(New LiteralControl(dr(dc.ColumnName).ToString))



I would like specific columns, by name or position doesnt matter.

So if a column is = named column, then addcell

and also, the data needs to be interpreted: If value of column = x then response.write("y")

In sum, I dont want all the columns, just specific ones, then I was to interpret whats in that cell, and write something.

For Each dc In ds.Tables(0).Columns

Creating indexed view from the table which has no index?



Can we create indexed view from the base table which has no index?

This is because i don't want any indexes in my base table but for better query performance i want in view..

Please suggest..

Thanks in advance,


WPF Creating a Table


Hi All ,

Am doing a wpf application..

I have a button and i want to create a table by clicking on that button. And the table should be like that there itself the user can insert column names and data also

first it may come with 1 or 2 rows and after entering into last row it should create 1 more row automatically

how can i do this ??

if u have any examples or links or suggestion please provide me...

Thanks in advance.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend