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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:33:06+00:00 2026-06-05T06:33:06+00:00

I have never used Case before and am not sure how to do this

  • 0

I have never used Case before and am not sure how to do this but we have had some issues doing a wholesale update because of addresses changing that are now coming in the data that did not used to. I am trying to use it as an if then statement but I am sure that I am doing wrong. I need to update addresses when a field is either empty or null.

UPDATE    defendants_ALL_Fixed
SET              tiffAdd = tiffAdds.Add1, tiffZip = tiffAdds.Zip, tiffCity = tiffAdds.City, tiffState = tiffAdds.State
FROM         defendants_ALL_Fixed INNER JOIN
                      tiffAdds ON defendants_ALL_Fixed.tiff = tiffAdds.Tiff
WHERE     (defendants_ALL_Fixed.tiff = tiffAdds.Tiff)

I have tried wrapping that into a case statement such as:

SELECT
  a.tiffAdd
, CASE WHEN a.tiffAdd = '' THEN

UPDATE    defendants_ALL_Fixed
SET              tiffAdd = tiffAdds.Add1, tiffZip = tiffAdds.Zip, tiffCity = tiffAdds.City, tiffState = tiffAdds.State
FROM         defendants_ALL_Fixed INNER JOIN
                      tiffAdds ON defendants_ALL_Fixed.tiff = tiffAdds.Tiff
WHERE     (defendants_ALL_Fixed.tiff = tiffAdds.Tiff)

END
FROM defendants_ALL_Fixed a

Which did not work and I understand why it does not work but have no idea where to go from here and any help would be great. We only use this once a month to update data (about 1.5 million records) and the resources it uses is not at all relevant at this point.

Thanks.

  • 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-05T06:33:13+00:00Added an answer on June 5, 2026 at 6:33 am

    Assuming i am understanding your question (i.e. only update defendants_ALL_Fixed fields with tiffAdds when the defendants_ALL_Fixed fields are blank), you could do this as follows (sticking with case):

    UPDATE  defendants_ALL_Fixed
    SET     tiffAdd = CASE WHEN LTRIM(RTRIM(ISNULL(tiffAdd, ''))) = '' THEN tiffAdds.Add1
                           ELSE tiffAdd
                      END ,
            tiffZip = CASE WHEN LTRIM(RTRIM(ISNULL(tiffZip, ''))) = '' THEN tiffAdds.Zip
                           ELSE tiffZip
                      END ,
            tiffCity = CASE WHEN LTRIM(RTRIM(ISNULL(tiffCity, ''))) = '' THEN tiffAdds.City
                            ELSE tiffCity
                       END ,
            tiffState = CASE WHEN LTRIM(RTRIM(ISNULL(tiffState, ''))) = '' THEN tiffAdds.State
                             ELSE tiffState
                        END
    FROM    defendants_ALL_Fixed
            INNER JOIN tiffAdds ON defendants_ALL_Fixed.tiff = tiffAdds.Tiff
    

    A simpler (or rather, easier to read) option is to do simple update statements based on a WHERE clause (one update statement per column):

    UPDATE  defendants_ALL_Fixed
    SET     tiffAdd = tiffAdds.Add1
    FROM    defendants_ALL_Fixed
            INNER JOIN tiffAdds ON defendants_ALL_Fixed.tiff = tiffAdds.Tiff
    WHERE   ( LTRIM(RTRIM(ISNULL(tiffAdd, ''))) = '' )
    

    Edit 1: based on your comment, That would suggest you can just update all columns where tiffAdd = ”? i.e.

    UPDATE  defendants_ALL_Fixed
    SET     tiffAdd = tiffAdds.Add1 ,
            tiffZip = tiffAdds.Zip ,
            tiffCity = tiffAdds.City ,
            tiffState = tiffAdds.State
    FROM    defendants_ALL_Fixed
            INNER JOIN tiffAdds ON defendants_ALL_Fixed.tiff = tiffAdds.Tiff
    WHERE   LTRIM(RTRIM(ISNULL(tiffAdd, ''))) = ''
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never used Try-catch in my code before, but now I need to
First some background on the questions. I have never used ravedb before and I'm
Update 2 : So I never have used the debug function in firebug, but
I have been doing socket programming for many years, but I have never had
I have never used Windsor before but have used other DI frameworks, and I
I have never used ruby but need to translate this code to java. Can
I have never used Perl, but I am really impressed by the ack ,
I have never used array_combine before and I am getting a Boolean instead of
I am new ASP.NET and I have never used a GridView or DataGrid, but
Just trying to understand that - I have never used it before. How is

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.