Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6170275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:00:17+00:00 2026-05-23T23:00:17+00:00

Some facts about my data I have a TablePattern that defines periodic day pattern

  • 0

Some facts about my data

  1. I have a TablePattern that defines periodic day pattern (usually long from few days and up to 28)
  2. Day pattern is stored as varbinary(4) as bit flags. Some days are on (set to 1 == true), others are off (set to 0 == false). There’s also Length column that defines pattern length stored in the binary column
  3. Each pattern record also has information whether weekends and holidays nullify pattern settings (explained later)
  4. I have table Holidays that defines holidays (some repeatable others fixed on a particular year)
  5. I have TableCalendar where I need to create X number of records. One for each day.

The problem

When generating records

  1. I know which pattern to use
  2. I know date range of days whose records I have to create
  3. Along with pattern I also know whether weekends/holidays take presence over pattern settings – this means that when I will be generating records it will automatically set them to false even though pattern says it should be true
  4. I also have additional Offset that tells me how to apply the pattern to my date range – if offset == 0 pattern starts at the first day; offset == 3 pattern starts on fourth day; offset is always between 0 and pattern length less 1 (in range of pattern length modulo values)
  5. all days before offset also have to be set as if pattern has started earlier (before starting day of the date range)

Questions

I have basically two options:

  1. I can generate calendar data on the middle tier, which would make it simpler, but would require a lot of DB calls to insert each record into TableCalendar.
  2. I can write a stored procedure and provide it:

    • date range
    • pattern record ID
    • offset

    and then write all the logic that would generate and insert records into TableCalendar. I can’t even imagine how to write this complex stored procedure that would use binary pattern and apply it with offsets etc.

Date ranges will usually be 1, 3 and 12 months long the second one being the most frequent one.

And since this generation is part of a web application’s Ajax call it has to be as snappy as possible. That’s the only reason I suppose that generating all records with a singe DB call would be faster than making lots of DB calls and execute some extremely simple insert statement. But I’m pretty sure that SP will become quite complex hance can also become sluggish.

What would you suggest I should do?

You can as well provide some TSQL code that would show how to generate those records using data I provided in a stored procedure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:00:17+00:00Added an answer on May 23, 2026 at 11:00 pm

    You do know you can insert multiple row in one insert. If you can sort your data by the clustered index you will get much faster insert. Change your fill on SQL. TSQL does not like more than 999 rows so I load 900 rows at a time. It is pretty fast – I am inserting 1,000 rows a second on a slow server.

        Insert Into [WFbchDocs] with (holdlock)
        ([wfID], [bchID], [sID], [folderID]) Values 
         ('1','11','2','1') 
        ,('1','11','3','1') 
        ,('1','11','4','1') 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some C++ code that will have to send data over TCP/IP. I
I have a COM (C++) API that listens for data updates from a server
I have some commits that I've decided, after the fact, are going to be
I only want facts as far as possible. There are some things that ASP.Net
I've been doing some thinking about data redundancy, and just wanted to throw everything
I have some code that I want to refactor. I have lots of methods
I have a data set of about 1000 face images, I need to use
I am getting some strange behavior involving database queries that I have never seen
I have a relatively large set of data that lends itself very naturally to
I have a SQL table that all of a sudden cannot return data unless

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.