Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Command?

Status
Not open for further replies.

Seabz420

IS-IT--Management
Jul 14, 2003
129
CA
I have a nvarchar field (COLDES) in the db COL. I need to replace any comma in the field with a space (there are about 10,000 records to go through). I've created a Stored Procedure that looks like this:

CREATE PROCEDURE [dbo].[LoanAnalysis_Update] AS
BEGIN
UPDATE COL
SET COLDES = REPLACE([COLDES],","," ")
END
GO

I'm I reaching in the right direction?
 
Here is the text from BOL:

REPLACE
Replaces all occurrences of the second given string expression in the first string expression with a third expression.

Syntax
REPLACE ( 'string_expression1' , 'string_expression2' , 'string_expression3' )

Arguments
'string_expression1'

Is the string expression to be searched. string_expression1 can be of character or binary data.

'string_expression2'

Is the string expression to try to find. string_expression2 can be of character or binary data.

'string_expression3'

Is the replacement string expression string_expression3 can be of character or binary data.

Return Types
Returns character data if string_expression (1, 2, or 3) is one of the supported character data types. Returns binary data if string_expression (1, 2, or 3) is one of the supported binary data types.

Examples
This example replaces the string cde in abcdefghi with xxx.

SELECT REPLACE('abcdefghicde','cde','xxx')
GO



SQL/SAP DBA
 
This worked!

UPDATE COL
SET COLDES = REPLACE((COLDES),',',' ')

Thanks everyone!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top