well my query is - select * from table where username like '[ks'+'%'
actually m using hindi font kruti dev 010 on UI so i need to search like this but wanna know wats the problem with '[' m unable to search data on the basis of '[' my column datatype is nvarchar in table
Sql Query
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Jun 12, 2014, 1:22 AM EDT
http://technet.microsoft.com/en-US/library/ms179859(v=sql.100).aspx
If you want to use it with its natural meaning, then you have to 'escape' it:
Here are two ways in which you could do that:
select * from table where username like '[[]ks%'
or:
select * from table where username like '![ks%' escape '!'
Anupam SinghRank #643 · 3.7K reputationPosted Jun 11, 2014, 6:12 AM EDT
try : select * from table where username like 'ks%'
will work as expected.
Sagar93 reputationPosted Jun 11, 2014, 10:56 PM EDT
Khan Abrar AhmedRank #778 · 3K reputationPosted Jun 12, 2014, 2:21 AM EDT
DECLARE @table AS TABLE (cValue VARCHAR(64))
INSERT INTO @table
( cValue )
VALUES
( '[ks' -- cValue - varchar(64)
),
( 'ks' -- cValue - varchar(64)
)
select * from @table
select * from @table where cValue like '[[]%'