Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
j4ydh
Starting Member
18 Posts |
Posted - 2013-05-13 : 06:04:41
|
HelloI have a select replace statement that works like a dream apart from if the item isn't found:REPLACE(REPLACE (Content, '<xSomethingx>', @Something), '<xSomethingElsex>', @SomethingElse) AS ContentRepSo if <xSomethingElsex> isn't found within the field nvarchar(MAX) NULL is returned.Any advice would be appreciatedThank you in advanceJ |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-13 : 06:48:51
|
Thats not true. It wont return NULL if it cant find search string. NULL will be returned only if any of variables like @SomethingElse has NULL value------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
j4ydh
Starting Member
18 Posts |
Posted - 2013-05-13 : 07:25:35
|
HiThe results returned are NULL / NOTHING in the results pane if the <xSomethingElsex> is not in the initial string.Should I consider IF exists or am I completely of track.ThanksJ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-13 : 07:34:35
|
can you show how your sample data is?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
j4ydh
Starting Member
18 Posts |
Posted - 2013-05-13 : 07:46:56
|
The data is HTML (table)Snippet:<tr><td colspan="3"><xSomethingx> <xSomethingElsex></td></tr>nvarchar(MAX)Replace works nicely as long as both <xSomethingx> and <xSomethingElsex> are in the string.If the field only has <tr><td colspan="3"><xSomethingx></td></tr>The results are "Nothing" because the parameter is also looking for <xSomethingElsex>RegardsJ |
|
|
|
|
|