home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 17,722 of 19,505   
   Hugo Kornelis to bill   
   Re: String Manipulation: REPLACE multipl   
   18 Dec 09 11:14:41   
   
   d6b42fff   
   From: hugo@perFact.REMOVETHIS.info.INVALID   
      
   On Thu, 17 Dec 2009 17:32:12 -0800 (PST), bill wrote:   
      
   >I want to convert this sample string:   
   >"Some like  better than .  I like  better   
   >than , but my daughter prefers ."   
   >   
   >To this one:   
   >"Some like cats better than dogs.  I like dogs better   
   >than cats, but my daughter prefers cats."   
   >   
   >Thus,  gets replaced with 'cats' and  gets replaced   
   >with 'dogs'.   
   (snip)   
   >I would much rather make a little table that had the variables and   
   >their values:   
   (snip)   
   >Then, I would like to issue a statement that joins the phrase to the   
   >substitution tables and does the REPLACES for all variables without   
   >requiring lots of nesting.   
      
   Hi Bill,   
      
   If it's just the one phrase (in a variable), then this works on my   
   database:   
      
   SELECT @phrase_tx = REPLACE(@phrase_tx, variable_nm, variable_value_tx)   
   FROM   phrase_variable   
   OPTION (MAXDOP 1);   
      
   I'm not 100% sure if this is fully documented and supported though.   
      
   --   
   Hugo Kornelis, SQL Server MVP   
   My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca