would adding a trigger that will format the field to only be characters upon inserts and updates be sufficient?
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
here is my idea then
select translate('123AB45',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ') from dual;
i don't necessarily know the context of how you need this, but this will replace all numeric values with '' and leave your string 123AB45 as AB
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
Ahhh sorry, forgot you only needed sql server
here's a link that should help
http://www.nigelrivett.net/SQLTsql/RemoveNonNumericCharacters.html
here it is with modification
CREATE FUNCTION dbo.AlphaOnly(@value varchar)
RETURNS VARCHAR
AS
BEGIN
DECLARE @returnVar varchar, @i int
SET @returnVar = @value
select @i = patindex('%[^a-zA-Z]%', @returnVar )
while @i > 0
begin
select @returnVar = replace(@returnVar, substring(@returnVar , @i, 1), '')
select @i = patindex('%[^a-zA-Z]%', @returnVar)
end
return @returnVar
END
you can use this udf in a trigger
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143