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
Loading
VulpesPosted Jun 12, 2014, 5:22 AM
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 '!'
Khan Abrar AhmedPosted Jun 12, 2014, 6:21 AM
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 '[[]%'
SagarPosted Jun 12, 2014, 2:56 AM
Anupam SinghPosted Jun 11, 2014, 10:12 AM
try : select * from table where username like 'ks%'
will work as expected.