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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:25:33+00:00 2026-06-09T12:25:33+00:00

I was helped out with this select query that I am using to get

  • 0

I was helped out with this select query that I am using to get all tables with null values in two columns

select count(*)
from (
   select LastModifiedDate from Table1
      union all
   select LastModifiedDate from Table2
      union all
   select LastModifiedDate from Table3
) a 
where LastModifiedDate is null

To update all three tables is there a better way to do it then

Update table1
SET LastModifiedDate = GETDATE()
WHERE LastModifiedDate is null

Update table2
SET LastModifiedDate = GETDATE()
WHERE LastModifiedDate is null

and so on?
Sorry I split the query’s one looks for CreationDate and one looks for LastModifiedDate

  • 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-06-09T12:25:35+00:00Added an answer on June 9, 2026 at 12:25 pm

    Yes, there is a better way. As Gordon Linoff noted in the comments, you might overwrite valid created dates with your proposed query.

    Try this instead:

    Update table1
    SET CreationDate = ISNULL(CreationDate,GETDATE())
      , LastModifiedDate = GETDATE()
    WHERE CreationDate is null or LastModifiedDate is null
    
    Update table2
    SET CreationDate = ISNULL(CreationDate,GETDATE())
      , LastModifiedDate = GETDATE()
    WHERE CreationDate is null or LastModifiedDate is null
    
    Update table3
    SET CreationDate = ISNULL(CreationDate,GETDATE())
      , LastModifiedDate = GETDATE()
    WHERE CreationDate is null or LastModifiedDate is null
    

    Using ISNULL will preserve existing CreationDate data. You don’t want to use it for LastModifiedDate, because you’re going to be modifying the rows, so that value should change.

    However, there’s no reason to try and restructure your statements, as there’s nothing wrong with them.

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

Sidebar

Related Questions

This answer has helped me largely but hasn't fully resolved my issues. I'm using
I am using a rails helper that creates 3 select lists for the purpose
I'm sure glad this site is here. It has helped me out every time.
I have the following query: SELECT location, step, COUNT(*), AVG(foo), YEAR(start), MONTH(start), DAY(start) FROM
I have this Linq to SQL query sequence that is basically returning a search
Issue has been resolved. Thank you to all whom posted and helped me out.
This is the last part of this project, thanks to all who've helped with
After the you guys helped me out so gracefully last time, here is another
simonn helped me to code an ordered integer partition function here. He posted two
JD Long helped me with this: question about manual annotation . But is it

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.