Remove Characters in String T-SQL with No Loop Part 2

Okay, expanding on what I did yesterday.

I Built a table, called ExclusionList with one field, ExcludedText

E.g.

Untitled2

Then created a function:

CREATE FUNCTION [dbo].[udf_clean_string]
	(
	@string VARCHAR(100)
	) RETURNS VARCHAR(100)
AS
BEGIN	

SELECT
    @string = REPLACE(@string,ExcludedText,'')
FROM ExclusionList

RETURN @string

You can then use like this:

SELECT
	dbo.udf_clean_string(FieldName)
FROM TableName
This entry was posted in Programming and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s