SSIS and Sql Server Journey

Personal Notes of Sarabjit Singh and Bhavpreet Singh

Function to replace all special characters – Sql Sever

on March 19, 2012
CREATE FUNCTION dbo.RemoveSpecialCharacter(@Str NVARCHAR(MAX))
RETURNS NVARCHAR(MAX)
AS
BEGIN

	SET @Str = Replace(@str, Char(13), ' ')
--replace all enters with space
	SET @Str = Replace(@str, Char(9), ' ')
--replace all tabs with space
	SET @Str = Replace(@str, Char(10), ' ')
--replace all line feeds with space

	RETURN @Str

END

Useful function to be used for data export to excel sheet(Using SSIS) as the “Enter” makes the data to move to next line and the reports gets distoreted.

Advertisements

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

%d bloggers like this: