TSQL function to compare two strings

sql, sql-server, user-defined-functions

Solution

Not really sure what you are looking for. From your question, I understand that you need to check 2 email addresses for similarity / dissimilarity.

Why can you not use this?

declare @email1 varchar(100) set @email1 = 'billg@microsoft.com'
declare @email2 varchar(100) set @email2 = 'melinda@microsoft.com'
IF
@email1=@email2
BEGIN
    PRINT 'Same Email'
END
ELSE
BEGIN
    PRINT 'Not Same Email'
END

Raj

Problem

Can anyone give me some sample TSQL code to compare two email addresses to check they are equal or not? CLR functions are not an option. I tried that but our DBA for some reason is totally against using CLR functions in SSMS. I know how to get the domain names (eg: mycompany.com) from the email address. Really appreciate any suggestions Thanks in advance

Original source