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 4583960
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:17:14+00:00 2026-05-21T21:17:14+00:00

I implement a software application that uses a SQL server database. I’m running a

  • 0

I implement a software application that uses a SQL server database. I’m running a stored proc in a macro I created in my application, however, I cannot get the “StartTime” (datetime field) to update. Here is the code:

ALTER PROCEDURE [dbo].[pAfterFirstRun] ( @scheduleDate datetime ) AS
BEGIN

    SET NOCOUNT ON;

    CREATE TABLE #VehicleId ( VehicleId INT )

    INSERT INTO #VehicleId 
       (VehicleId) 
    SELECT VehicleId 
      FROM ResourceDaily 
     WHERE WorkDay = @scheduleDate 
       AND ResourceName = 'RUN 1' 
       AND ResourceCode IN (SELECT ResourceCode 
                              FROM ResourceDailySchedule 
                             WHERE WorkDay = @scheduleDate)

    UPDATE ResourceDaily 
       SET StartTime = '1899-12-30 07:20:00.000' 
     WHERE WorkDay = @scheduleDate 
       AND ResourceName = 'RUN 2' 
       AND VehicleId IN (SELECT VehicleId 
                           FROM #VehicleId)

    UPDATE ResourceDaily 
       SET StartAddress = '568 BUCKS HILL RD', 
           StartCity = 'WATERBURY', 
           StartState = 'CT', 
           StartZipCode = '06704', 
           StartXCoord = '-73.029938', 
           StartYCoord = '41.606228' 
     WHERE WorkDay = @scheduleDate 
       AND ResourceName = 'RUN 2' 
       AND VehicleId IN (SELECT VehicleId 
                           FROM #VehicleId)

END

I know this is a strange way to accomplish the job; originally, I didn’t create a temp table. It was all done through one update statement and I kept changing it to see if I can get it to work.

The original update statement included the updates to StartTime, StartAddress, StartCity, StartState, StartXCoord and StartYCoord all in one statement and everything would update except the StartTime field.

I should also mention that if I were to run the UPDATE statement in Management Studio and set the @scheduleDate to ‘5/2/2011’, the update statement will run correctly… it just doesn’t seem to run in the application with the @scheduleDate parameter.

  • 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-21T21:17:15+00:00Added an answer on May 21, 2026 at 9:17 pm

    this seems to be data dependent, so run your procedure manually from SQL Server Management Studio, after making these changes to it:

    ALTER PROCEDURE [dbo].[pAfterFirstRun] ( @scheduleDate datetime ) AS
    BEGIN
    
        SET NOCOUNT ON;
    
        CREATE TABLE #VehicleId ( VehicleId INT )
    
        INSERT INTO #VehicleId 
           (VehicleId) 
        SELECT VehicleId 
          FROM ResourceDaily 
         WHERE WorkDay = @scheduleDate 
           AND ResourceName = 'RUN 1' 
           AND ResourceCode IN (SELECT ResourceCode 
                                  FROM ResourceDailySchedule 
                                 WHERE WorkDay = @scheduleDate)
    --debug
    SELECT '#VehicleId' AS "#VehicleId",* FROM #VehicleId 
    --debug
    SELECT 'UPDATE 1', AS "UPDATE 1", * FROM ResourceDaily 
         WHERE WorkDay = @scheduleDate 
           AND ResourceName = 'RUN 2' 
           AND VehicleId IN (SELECT VehicleId 
                               FROM #VehicleId)
    
        UPDATE ResourceDaily 
           SET StartTime = '1899-12-30 07:20:00.000' 
         WHERE WorkDay = @scheduleDate 
           AND ResourceName = 'RUN 2' 
           AND VehicleId IN (SELECT VehicleId 
                               FROM #VehicleId)
    
    --debug
    SELECT 'UPDATE 2', AS "UPDATE 2", * FROM ResourceDaily 
         WHERE WorkDay = @scheduleDate 
           AND ResourceName = 'RUN 2' 
           AND VehicleId IN (SELECT VehicleId 
                               FROM #VehicleId)
    
    
        UPDATE ResourceDaily 
           SET StartAddress = '568 BUCKS HILL RD', 
               StartCity = 'WATERBURY', 
               StartState = 'CT', 
               StartZipCode = '06704', 
               StartXCoord = '-73.029938', 
               StartYCoord = '41.606228' 
         WHERE WorkDay = @scheduleDate 
           AND ResourceName = 'RUN 2' 
           AND VehicleId IN (SELECT VehicleId 
                               FROM #VehicleId)
    
    END
    

    I added 3 debug queries, which will return result sets that you need to look at and understand before you can solve this. I don’t know your application or what you are trying to do well enough to fix this for you, but you need to see what your queries are doing before your can solve it. I wouldn’t be surprised if it ends up being that #VehicleId is empty after the insert into it. If so, look out for time on the @scheduleDate parameter and time on the WorkDay column values not joining properly. Look into Floor a date in SQL server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work on an Internet-facing, ASP.NET-based product that uses SQL Server 2005. Most customers
I wish to implement my software on a shareware basis, so that the user
I'm about to implement a feature in our application that allows the user to
I am working on a software development project that uses code written primarily in
I'm developing an application that will need to communicate with itself running on different
I have a GWT application that I want to release as software-as-a-service (SAAS) on
I've just recently built a Silverlight application that communicates with a server via WCF.
I want to implement every-minute database stored procedure executing in ASP.NET MVC web site
I am trying to implement a software Null Modem . Any suggestion how to
Is it legal to write instant message software that implements MSN Messener, Yahoo! Messener,

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.