Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 User Defined Function Issues

Author  Topic 

bhushanpost
Starting Member

1 Post

Posted - 2011-07-08 : 05:35:08
Hi SQLExperts,
I have created a user defined function to remove special characters other than present in the keyboard(e.g.chinese symbols etc).The code is as follows:
CREATE FUNCTION dbo.RemoveChars10(@Input varchar(1000))
RETURNS VARCHAR(1000)
BEGIN
o
SET @Pos = PATINDEX('%[^a-z,A-Z,0-9,,!@#$%^&*()-{} : ; < >? / \ _ ? " '']%',@Input)
WHILE @Pos > 0
BEGIN
SET @Input = STUFF(@Input,@pos,1,'')
SET @Pos = PATINDEX('%[^a-z,A-Z,0-9,,!@#$%^&*()-{} : ; < >? / \ _ ? " '']%',@Input)
END
RETURN @Input
END
GO


This function is working fine.we are using peoplesoft application and SQL server 2008 is our database.My question is:
Will there be any negative impacts(during Tools upgrade or cancellation of certificates if problem occurs with user-defined functions) in creating the user defined function in MS SQL server 2008?

Bhushan
CTS,Chennai.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-07-08 : 05:52:48
Are the tools upgrade and cancellation of certificates related to Peoplesoft application? Such changes should not have any impact on this function and this function would not affect such upgrades/cancellations. However, two comments about the function:

1. May be it is because you have not posted the whole function, but it does not seem to have the correct syntax. For example, variable @Pos is not defined.

2. The query is likely to be slow because of the looping. If you know in advance what the characters you want to remove are, nested replace would be faster.
Go to Top of Page
   

- Advertisement -