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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:56:40+00:00 2026-06-05T22:56:40+00:00

I am updating a table with spatial types and there are three or more

  • 0

I am updating a table with spatial types and there are three or more updates that I might have to perform to make sure that the geometry type is successfully loaded into a geography type. What I want to do is to us the first update and commit as many rows as possible, then use the second update where the first one failed and lastly, use the third update where the second one failed.

I successfully managed to do did this manually and updated all the geography types using the geometry types. These are the statements that I am using:

Update statement #1:

Update Postcode set geog = geography::STGeomFromWKB(geom.STAsBinary(), 4326)
FROM Postcode
WHERE geog is null

Update statement #2:

Update Postcode set geog = geography::STGeomFromWKB(geom.STUnion(geom.STStartPoint()).STAsBinary(), 4326)
FROM Postcode
WHERE geog is null

Update Statement #3:

Update Postcode set geog = geography::STGeomFromWKB(geom.STBuffer(0.00001).STBuffer(-0.00001).STAsBinary(), 4326) 
FROM Postcode 
WHERE geog is null

Is there a way to write this so that it lets me update rows wherever error is not encountered and then move on to the next update statement in case of an error?

I hope it makes sense and any help will be greatly appreciated.

  • 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-05T22:56:41+00:00Added an answer on June 5, 2026 at 10:56 pm

    If there is a way to test each assignment without actually throwing an error, then a preferred approach is to use CASE statement to switch among them.

       update postcode set geog = case when <test> then <A>
                                       when <testB> then <B>
                                       else <C>
                                  end
    

    Otherwise if an error cannot be avoided, then nested try/catch blocks can be used to ensure execution. However when an error occurs within a given statement, that whole statement may be rolled back (not 100% sure here). You sounded like you would be happy if you could just run all three statements so not sure if this is an issue.

        BEGIN TRY
            -- A
        END TRY
        BEGIN CATCH
            BEGIN TRY
                -- B
            END TRY
            BEGIN CATCH
                -- C
            END CATCH         
        END CATCH
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem in updating date. My first table is DONOR donor-nic----username-----status
I'm having a problem updating a table and im sure its pretty straight forward
I am using greasemonkey script and have updating the table using following code. I
I have a MySQL table from a third-party application that has millions of rows
We have a SQL Server database table that consists of user id, some numeric
I have tried to perform update on table which was trigger by update on
I have a table called pano_raw that has 3 columns lat, lng, and latlng.
I have created a small test for updating table using Linq-to-SQL DataContext as follows:
I have a question about updating table through t-sql. The client may want to
Suppose you're updating a table that is the result of an expression, like so

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.