如何在ms SQL server中搜索区分大小写的数据,如 user_name 和密码。 在MySQl中,它由 BINARY()函数完成。
答案 0 :(得分:1)
使用区分大小写的collate创建列,并尝试以下操作:
<强>查询:强>
DECLARE @temp TABLE
(
Name VARCHAR(50) COLLATE Latin1_General_CS_AS
)
INSERT INTO @temp (Name)
VALUES
('Ankit Kumar'),
('DevArt'),
('Devart')
SELECT *
FROM @temp
WHERE Name LIKE '%Art'
<强>输出:强>
DevArt
或尝试使用此类似代码 -
DECLARE @temp TABLE (Name NVARCHAR(50))
INSERT INTO @temp (Name)
VALUES
('Ankit Kumar'),
('DevArt'),
('Devart')
SELECT *
FROM @temp
WHERE Name LIKE '%Art' COLLATE Latin1_General_CS_AS
答案 1 :(得分:1)
可以使用Casting to Binary
来完成此操作SELECT * FROM UsersTable
WHERE
CAST(Username as varbinary(50)) = CAST(@Username as varbinary(50))
AND CAST(Password as varbinary(50)) = CAST(@Password as varbinary(50))
AND Username = @Username
AND Password = @Password