|
SQL to Replace String in Sybase
|
|
12-09-2009, 05:15 PM
Post: #1
|
|||
|
|||
|
SQL to Replace String in Sybase
How to replace string with another string in sybase?
str_replace Description Replaces any instances of the second string expression (string_expression2) that occur within the first string expression (string_expression1) with a third expression (string_expression3). Syntax replace("string_expression1", "string_expression2", "string_expression3") Parameters string_expression1 is the source string, or the string expression to be searched, expressed as char, varchar, unichar, univarchar, varbinary, or binary datatype. string_expression2 is the pattern string, or the string expression to find within the first expression (string_expression1). string_expression2 is expressed as char, varchar, unichar, univarchar, varbinary, or binary datatype. string_expression3 is the replacement string expression, expressed as char, varchar, unichar, univarchar, binary, or varbinary datatype. Examples Example 1 Replaces the string def within the string cdefghi with yyy. replace("cdefghi","def","yyy")------------- cyyyghi (1 row(s) affected) Example 2 Replaces all spaces with "toyota". select str_replace("chevy, ford, mercedes", "","toyota")---------- chevy,toyotaford,toyotamercedes (1 row(s) affected) NoteAdaptive Server converts an empty string constant to a string of one space automatically, to distinguish the string from NULL values. Example 3 Returns “abcghijklm”: select str_replace("abcdefghijklm", "def", NULL) ---------- abcghijklm (1 row affected) For more information refer to str_replace in sybase manual. |
|||
|
« Next Oldest | Next Newest »
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies: | Views: | Last Post | |
| Need help in converting String to Date format | surbhit4u | 0 | 138 |
06-22-2010 01:05 PM Last Post: surbhit4u |
|
| String concatenation operator in Sybase T-SQL | Joshi | 0 | 609 |
02-03-2010 11:06 PM Last Post: Joshi |
|
| REPLACE function [String] in Sybase Adaptive Server(ASE) | crazYoga | 0 | 609 |
02-02-2010 02:18 AM Last Post: crazYoga |
|
| Replace string in Sybase | Joshi | 0 | 175 |
09-09-2009 01:49 AM Last Post: Joshi |
|
| sybase string functions with examples | john | 0 | 636 |
07-07-2009 02:30 AM Last Post: john |
|
| T-SQL: A Simple Way to Build a String from a Column | zaadmin | 0 | 227 |
10-10-2008 09:50 PM Last Post: zaadmin |
|


Chat Support
Search
Disclaimer & Rules
Help


