create function getUserName (@Name varchar(120)) returns varchar as begin declare @UserName varchar(24) if len(@Name)>12 Set @UserName=substring(@Name,1,12) return @UserName
end go