Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2005
    Posts
    40

    Unanswered: Create Function?

    Is a function the best method/what's the funciton code? Two tables, one table with values that need to be converted from a varchar data type to a money data type, depending on the other's table value. For example,

    I have values of:

    table1:
    0000853A
    0000057F


    table2/lookup table:
    A means replace A with +1, making table1 value to be 8531
    F means replace F with +6, making table1 value to be 576

    Thanks!

  2. #2
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    4
    can you eloborate your requirement...

  3. #3
    Join Date
    Apr 2005
    Posts
    40
    This requirement is to convert the letter to a number using the lookup table. Table2 has the field1, field2. Field1 is A, field2 is what A means which is 1. Table1 has many values, such as 0000853A. This needs to be updated in this table1 to 00008531....the A turns to a 1.

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Code:
    select left(t1.x,7)+t2.z
    from 
    (select
    '0000853A' union all select
    '0000057F' 
    )t1(x)
    join
    (select 
    'A', 1 union all select
    'F', 6
    )t2(y,z)
    on t2.y=right(t1.x,1)
    Now I'll leave it up to you to change it to an update

  5. #5
    Join Date
    Apr 2005
    Posts
    40
    I'll pass-it's more dynamic.....half way into developing this thing....I guess I'm going to use a function within a cursor to update the individual rows. function will pull from the lookup table a value dependent upon the rendered value by the other table, then update that rendered value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •