문제

Hi Can anyone help me with a Regular expression to extract the value of Initial Catalog from a Connection String ?

  'Data Source=server\instance;Initial Catalog=MyDatabase;Integrated Security=True'

I want to extract 'MyDatabase' from the connection string

   Catalog=(?s)(.*); 

Using above mentioned Expression. I want only the Database name. How can i make it ignore Catalog and ; at the end and any possible blank spaces

도움이 되었습니까?

해결책

An SSIS Expression you can use in another variable to extract the Initial Catalog name.

SUBSTRING ( 
    SUBSTRING (  
        @[User:Connstring], 
        FINDSTRING (  
            @[User:Connstring],
            "Initial Catalog=",
            1),
        LEN (  @[User:Connstring])
    ),
    17,
    FINDSTRING ( 
        SUBSTRING (  
            @[User:Connstring],
            FINDSTRING (
                @[User:Connstring],
                "Initial Catalog=",
                1
            ),
            LEN ( @[User:Connstring])
        ),
        ";",
        1
    )  
    - 17
)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top