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.
| Author |
Topic |
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2004-12-06 : 15:00:42
|
| I created a function to remove some abbervistion from a name field. when i run the function, it is not replaceing the abbreviation with spaces. If the passed name have any abbrveiation like INC or CO or or CORP, I want them to be removed from the name and returnhere is the codecreate function ufnRemoveAbbr(@Name varchar(500))returns varchar(500)asbeginDeclare @Result varchar(500)set @result = replace(@name,'INC','')set @result = replace(@name,'CO','')set @result = replace(@name,'CORP','')return @Resultend |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-12-06 : 15:26:01
|
show some sample data...Go with the flow & have fun! Else fight the flow |
 |
|
|
Hippi
Yak Posting Veteran
63 Posts |
Posted - 2004-12-06 : 15:31:42
|
quote: Originally posted by cbeganesh I created a function to remove some abbervistion from a name field. when i run the function, it is not replaceing the abbreviation with spaces. If the passed name have any abbrveiation like INC or CO or or CORP, I want them to be removed from the name and returnhere is the codecreate function ufnRemoveAbbr(@Name varchar(500))returns varchar(500)asbeginDeclare @Result varchar(500)set @result = replace(@name,'INC','')set @result = replace(@name,'CO','')set @result = replace(@name,'CORP','')return @Resultend
How aboutcreate function RemoveAbbr(@Name varchar(500))returns varchar(500)asbeginDeclare @Result varchar(500)set @result = replace(@name,'INC','')set @result = replace(@result,'CORP','')set @result = replace(@result,'CO','')return @ResultendHTH |
 |
|
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2004-12-06 : 15:39:10
|
| It worked, I dont see any change to my code, is that ufn made the diffrence |
 |
|
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2004-12-06 : 15:40:39
|
| yes I see the mistake, Thanks |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-06 : 15:52:51
|
| [code]create function ufnRemoveAbbr(@Name varchar(500))returns varchar(500)asbegin return REPLACE(REPLACE(REPLACE(@Name,'INC',''),'CORP',''),'CO','')endGOSELECT dbo.ufnRemoveAbbr('x002548 CORP INC CO')GODROP FUNCTION ufnRemoveAbbrGO[/code]Brett8-) |
 |
|
|
|
|
|
|
|