Search results
Jun 28, 2013 · You don't need wildcards in the REPLACE - it just finds the string you enter for the second argument, so the following should work: UPDATE dbo.xxx SET Value = REPLACE(Value, '123', '') WHERE ID <=4 If the column to replace is type text or ntext you need to cast it to nvarchar
Jun 4, 2009 · I may be a year late to the party, but I work on queries & MS-SQL every day, and I got tired of the built-in functions LTRIM() & RTRIM() (and always having to call them together), and of not catching 'dirty' data that had newlines at the end, so I decided it was high time to implement a better TRIM function.
Aug 30, 2016 · SELECT REGEXP_REPLACE("Hello World SQL", "(Hello|World)", "") This will return SQL. With this process, the query will not look redundant and you didn't have to take care of multiple replace() clauses. Conclusion. If you wanted to replace the words with blank string, go with REGEXP_REPLACE().
May 2, 2009 · I have a table (SQL Sever) which references paths (UNC or otherwise), but now the path is going to change. In the path column, I have many records and I need to change just a portion of the path,...
Feb 8, 2021 · Language Extensions allow calling R / Python / Java code, hosted outside of SQL Server, via the sp_execute_external_script stored procedure. As the Tutorial: Search for a string using regular expressions (regex) in Java page shows, external scripts are actually not a good choice for many / most uses of RegEx in SQL Server. The main problems are:
Replace(@strip, '''', '') However, ordinarily you'd replace ' with '' and this will make SQL Server happy when querying the database. The trick with any of the built-in SQL functions (like replace) is that they too require you to double up your single quotes. So to replace ' with '' in code you'd do this: Replace(@strip, '''', ''''')
May 3, 2017 · Different ways to replace NULL in sql server. Replacing NULL value using: 1. ISNULL() function. 2.
Jan 6, 2022 · I've replaced some cursors with WHILE loops. DECLARE @SomeTable TABLE ( ID int IDENTITY (1, 1) PRIMARY KEY NOT NULL, SomeNumber int, SomeText varchar ) DECLARE @theCount int DECLARE @theMax int DECLARE @theNumber int DECLARE @theText varchar INSERT INTO @SomeTable (SomeNumber, SomeText) SELECT Number, Text FROM PrimaryTable SET @theCount = 1 SELECT @theMax = COUNT(ID) FROM @SomeTable WHILE (@theCount <= @theMax) BEGIN SET @theNumber = 0 SET @theText = '' SELECT @theNumber = IsNull(Number, 0 ...
Jan 8, 2013 · select REPLACE(ProductAlternateKey, ' ', '@') --type ALT+255 instead of space for the second expression in REPLACE from DimProducts where ProductAlternateKey like '46783815%' Raj Edit: Based on ASCII() results, try ALT+10 - use numeric keypad
Feb 19, 2022 · I know the original question was about simply replacing spaces, but should you need to replace ALL whitespace, you can use the TRANSLATE function (since Sql Server 2019) to convert a given list of characters to something easier to replace. Then wrap it with the REPLACE function.