Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Posts
    4

    Question Unanswered: Replacing Multiple rows with searched multiple values

    I have two tables..

    Table1.Field1 Values ("North Highway", "Green Street", "Blue Road", "Pink Lane")

    Table1.Field1 Values (" Road", " Lane", " Street", " Highway")
    Table2.Field2 Values (" Rd.", " Ln.", " St.", " Hwy.")

    I would like to create a function or a sp_ that searches Table1.Field1 for the values in Table2.Field1 AND replaces it with Table2.Field2

    Possible?
    How?

    It would of course be possible with a
    replace(replace(replace(Table1.Field1," Road"," Rd.")," Lane"," Ln.")," Street"," St.")

    But friends, I dont think I need to mention that this is purely an example..
    Table2 contains about 260 records.

    thnx.

    Marcus

  2. #2
    Join Date
    Jan 2003
    Location
    Duncan BC Canada
    Posts
    80
    Are the two tables related somehow? Does one have a foreign key pointing to a candidate key of the other?
    Bradley

  3. #3
    Join Date
    Apr 2003
    Posts
    4
    Originally posted by bcrockett
    Are the two tables related somehow? Does one have a foreign key pointing to a candidate key of the other?
    Nope, and that is the point with this, I'd like to create a function that can be used over and over again, on multiple tables.

    regards.
    marcus selander

  4. #4
    Join Date
    Jan 2003
    Location
    Duncan BC Canada
    Posts
    80
    If there's nothing in common between table one and table two, you can't do it.
    Bradley

Posting Permissions

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