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
Advertisements
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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s