下面的SQL查询适用于CASE WHEN中的所有检查,接受某些电子邮件。每当我运行查询检查电子邮件时,它有时会工作,有时它不会。我做了一个RTRIM(LTRIM(m.Email)),这也不起作用。 在比较电子邮件时,我需要做些什么吗?
exec BuildingPros.uspGetEmployees 1697,'Email','someone@somewhere.net'
alter proc BuildingPros.uspGetEmployees
@ProID INT,
@Where VARCHAR(12) = NULL,
@Equals VARCHAR(25) = NULL
AS
SELECT m.UserId,u.UserName,e.NonProID'ID',m.Email,c.FirstName'FName',c.LastName'LName',
ISNULL(c.Title,'NA')'Title',z.ZIPCode'Zip', p.Phone
FROM Person.UtbAddressesutbContact ac JOIN
Person.utbAddresses a ON ac.AddressID = a.AddressID JOIN
Person.utbContact c ON ac.ContactID = c.ContactID JOIN
Person.utbZipCodes z ON z.ZipCodeID = a.ZipCodeID JOIN
Person.utbCitys city ON city.CityID = z.CityID JOIN
Person.utbContactUtbPhones cp ON c.ContactID = cp.ContactID JOIN
Person.utbPhones p ON p.PhoneID = cp.PhonesID JOIN
NonPros.utbNonProsUtbAddresses ea ON a.AddressID = ea.AddressID JOIN
aspnet_Membership m JOIN
NonPros.NonPros e ON m.UserId = e.UserID ON ea.NonProID = e.NonProID JOIN
BuildingPros.utbProfessionalsUtbNonPros pe ON e.NonProID = pe.NonProID JOIN
dbo.aspnet_Users u ON u.UserId = m.UserId
WHERE
CASE @Where
WHEN 'Email' THEN m.Email
WHEN 'Name' THEN c.LastName
WHEN 'Zip' THEN z.ZIPCode
WHEN 'ST' THEN z.StateCD
WHEN 'Title' THEN c.Title
WHEN 'TimeZone' THEN z.TimeZone
WHEN 'City' THEN city.City
END = @Equals
答案 0 :(得分:4)
我怀疑它适用于长度短于26个字符且电子邮件长度为26个字符或更长的电子邮件。 VARCHAR(25)
不足以发送电子邮件地址。