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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:15:12+00:00 2026-05-15T16:15:12+00:00

So I have this SQL table that I need to update. Now we use

  • 0

So I have this SQL table that I need to update. Now we use a tool to do the process so if we just renamed the column then it wouldn’t work because our tool would just drop the old column and add a new column with the new name, so we have to do it manually and enter this code into the build and exclude the table from our build.

The table we CURRENTLY have has a column called ‘FeeTypeId’. We have another table, a Lookup table, that has a bunch of ID’s relating to types and descriptions. We want that previous ‘FeeTypeId’ field on the other table I just mentioned, to contain these LookupId’s which relate to their specific ‘FeeDescription’s. I will have an Excel sheet that contains the mappings, so for right now there is no real data, just logic.

Here is the script I wrote but I don’t know if it will run. Can you guys help me out?

----------------------------------------------------------------------
--PRE_UPGRADE--
----------------------------------------------------------------------

CREATE TABLE dbo.TmpFeesToRules(OldValue varchar, NewValue varchar)
--populate with values from Excel

----------------------------------------------------------------------
--POST UPGRADE--
----------------------------------------------------------------------

UPDATE Lending.ApplicationFee
    SET FeeTypeId = 
        CASE t.NewValue 
            WHEN <> null THEN (SELECT LookupID FROM tblLookup WHERE LookupType = 'FEE_CODE' AND LookupDesc = t.NewValue)
            ELSE (SELECT LookupID FROM tblLookup WHERE LookupType = 'FEE_CODE' AND LookupCode = 'OTHER') END
            -- else might change, might not even need an else

    FROM TmpFeesToRules t INNER JOIN tblLookup l ON t.NewValue = l.LookupDesc

    -- Drop the tmp table
    DROP TABLE dbo.TmpFeesToRules
  • 1 1 Answer
  • 1 View
  • 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-15T16:15:13+00:00Added an answer on May 15, 2026 at 4:15 pm

    I can’t really test this but the following is, according to Toad, valid SQL. Perhaps you can try to run this:

    UPDATE Lending.ApplicationFee
    SET FeeTypeId = 
    (
        CASE WHEN t.NewValue  IS NOT NULL THEN 
            (SELECT LookupID FROM tblLookup WHERE LookupType = 'FEE_CODE' AND LookupDesc = t.NewValue)
        ELSE 
            (SELECT LookupID FROM tblLookup WHERE LookupType = 'FEE_CODE' AND LookupCode = 'OTHER')
        END
    )
    FROM TmpFeesToRules t 
    INNER JOIN tblLookup l ON t.NewValue = l.LookupDesc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi there I have an SQL table that looks like this: CREATE TABLE IF
I need to get the last inserted id of table that have multi-column primary
I have this SQL Query that pulls data from 3 tables. I am unable
I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some
I have this sql statement: CREATE TABLE [dbo].[User]( [UserId] [int] IDENTITY(1,1) NOT NULL, [FirstName]
i have this sql query select * from table where name like ? but
I have this table structure on a SQL Server 2008 R2 database: CREATE TABLE
I have an SQL table like this : sales(product,timestamp) I want to display a
I have a 'users' SQL table structure like this (the ID is randomly generated
I have a 'users' SQL table structure like this (the ID is randomly generated,

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.