Reputation: 403
how to search case sensitive data like user_name and password in ms SQL server. In MySQl It is done by BINARY() function.
Upvotes: 2
Views: 344
Reputation: 11309
Can do this using 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
Upvotes: 1
Reputation: 122032
Create column with case sensitive collate, and try this:
Query:
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'
Output:
DevArt
Or try this similar code -
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
Upvotes: 1