declare @s char(5)
declare @r int
declare @i int
set @s='A1012'
if (ascii(substring(@s,1,1))>=65 and ascii(substring(@s,1,1))<=90) or
(ascii(substring(@s,1,1))>=97 and ascii(substring(@s,1,1))<=122)
set @r=1
else
set @r=0
set @i=2
while @i<=5
begin
if ascii(substring(@s,@i,1))>=48 and ascii(substring(@s,@i,1))<=57
set @r=@r*1
else
set @r=@r*0
set @i=@i+1
end
if @r>0
select 'the string is ok'
else
select 'the string is not ok'