Professional Web Applications Themes

Custom replacement function - Microsoft SQL / MS SQL Server

Hi. I am trying to create a custom replace function for my applications. I have a table with two columns where I store some words and their synonims. My function needs to read a string and verify that any of the words is present on the first field. If it is, I need to replace this word with the one present on the second field. The function then needs to return the changed string. Is it possible to do that in Sql server? Thanks, Robert Scheer...

  1. #1

    Default Custom replacement function

    Hi.

    I am trying to create a custom replace function for my applications. I
    have a table with two columns where I store some words and their
    synonims. My function needs to read a string and verify that any of
    the words is present on the first field. If it is, I need to replace
    this word with the one present on the second field. The function then
    needs to return the changed string. Is it possible to do that in Sql
    server?

    Thanks,

    Robert Scheer
    Robert Scheer Guest

  2. #2

    Default Re: Custom replacement function

    Try this and see if it works. I'd recomment you test this thoroughly before
    going live, as I haven't really relied on this behavior before:

    SET NOCOUNT ON
    GO

    CREATE TABLE #Abbr(abr varchar(10), expn varchar(100))
    GO

    INSERT #Abbr SELECT 'USA', 'United States Of America'
    INSERT #Abbr SELECT 'UK', 'United Kingdom'


    GO

    DECLARE i varchar(100)

    SET i = 'The USA and UK'

    UPDATE #Abbr SET i = REPLACE(i, abr, expn) FROM #Abbr

    SELECT i


    --
    HTH,
    Vyas, MVP (SQL Server)
    [url]http://vyaskn.tripod.com/[/url]
    What hardware is your SQL Server running on?
    [url]http://vyaskn.tripod.com/poll.htm[/url]




    "Robert Scheer" <rbscheermy-deja.com> wrote in message
    news:cfd22ab6.0306300951.62902de9posting.google.c om...
    Hi.

    I am trying to create a custom replace function for my applications. I
    have a table with two columns where I store some words and their
    synonims. My function needs to read a string and verify that any of
    the words is present on the first field. If it is, I need to replace
    this word with the one present on the second field. The function then
    needs to return the changed string. Is it possible to do that in Sql
    server?

    Thanks,

    Robert Scheer


    Narayana Vyas Kondreddi Guest

Similar Threads

  1. custom replacement of EditCommandColumn
    By news.microsoft.com in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: March 29th, 09:19 PM
  2. Canon Custom Function 04
    By Lester Wareham in forum Photography
    Replies: 3
    Last Post: December 24th, 01:43 AM
  3. pass variable to custom function not working MX
    By amphibianZ in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: March 3rd, 05:24 PM
  4. HELP: Custom DataReader Function - Tricky issue
    By VB Programmer in forum ASP.NET General
    Replies: 4
    Last Post: August 13th, 03:43 AM
  5. Asp custom function
    By Alessandro Ghidini in forum ASP Database
    Replies: 2
    Last Post: July 7th, 02:17 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139