ALL CAPS in Addresses

Howdy,

A lot of our clean-up is changing the names and addresses from all caps or all lower case.  Unfortunately we cannot force this format on our website.  Is there a way that this can be auto-corrected in Tessitura?  Or does anyone have a way to mass correct this another way.  Any advice or suggestions will help!

THANK YOU,

Jane

Parents Reply Children
  • Yeah sure 

    USE [impresario]
    GO
    
    /****** Object:  UserDefinedFunction [dbo].[FS_AllToProperCase]    Script Date: 5/05/2022 10:49:59 PM ******/
    SET ANSI_NULLS ON
    GO
    
    SET QUOTED_IDENTIFIER ON
    GO
    
    CREATE FUNCTION [dbo].[FS_AllToProperCase]( @name nvarchar(500) )
    RETURNS nvarchar(500)
    AS
    BEGIN
    declare @pos    int = 1
          , @pos2   int
    
    if (@name <> '')--or @name = lower(@name) collate SQL_Latin1_General_CP1_CS_AS or @name = upper(@name) collate SQL_Latin1_General_CP1_CS_AS)
    begin
        set @name = lower(rtrim(@name))
        while (1 = 1)
        begin
            set @name = stuff(@name, @pos, 1, upper(substring(@name, @pos, 1)))
            set @pos2 = patindex('%[- ''.)(]%', substring(@name, @pos, 500))
            set @pos += @pos2
            if (isnull(@pos2, 0) = 0 or @pos > len(@name))
                break
        end
    end
    
    return @name
    END
    GO
    

    There are probably cooler ways of doing it but if I was going to Proper all the Lower case "Street 1" 

    Begin transaction 
    
    declare  @Proper table 
    	(
    	Word varchar(4000),
    	ID int
    	)
    
    insert into @Proper (Word, ID)
    	select dbo.FS_AllToProperCase(street1) as test,
    	address_no
    from T_ADDRESS
    where street1 = LOWER(street1) collate SQL_Latin1_General_CP1_CS_AS
    and inactive='N'
    
    select * from @Proper
    
    select address_no,
    p.id,
    c.street1,
    p.Word
    
    from T_ADDRESS c
    Join @Proper p
    on address_no = p.ID
    
    
    --update T_ADDRESS 
    --SET street1 = p.word
    --from T_ADDRESS c
    --Join @Proper p on c.address_no = p.ID
    --where street1 = LOWER(street1) collate SQL_Latin1_General_CP1_CS_AS
    
    Rollback transaction