Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2009-08-26 : 09:54:54
|
| In T-SQL some characters like ' are reserve, for example if I want to search a name of a student which contian the keyword John I would write the following in my SELECT query.Select * from Student where name like 'John'Now what if I want to search a name that has the ' character, for example the name M'Cafe.Please suggest a select query for it.Thanks,Zee |
|
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2009-08-26 : 09:59:30
|
| Any quick help would be highly appreciated. |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-08-26 : 10:02:59
|
| Use double 'select * from Student where [name] like '%''%' |
 |
|
|
cat_jesus
Aged Yak Warrior
547 Posts |
Posted - 2009-08-26 : 10:03:41
|
| CREATE TABLE #temp (Userid VARCHAR(15),[Type] VARCHAR(5))INSERT INTO #temp SELECT 'A','x'''SELECT * FROM #temp WHERE [TYPE] LIKE '%''%'An infinite universe is the ultimate cartesian product. |
 |
|
|
maxbet
Starting Member
5 Posts |
Posted - 2009-08-26 : 10:04:17
|
quote: Originally posted by zeeshan13 In T-SQL some characters like ' are reserve, for example if I want to search a name of a student which contian the keyword John I would write the following in my SELECT query.Select * from Student where name like 'John'Now what if I want to search a name that has the ' character, for example the name M'Cafe.Please suggest a select query for it.Thanks,Zee
Select * from Student where name like 'M''Cafe' |
 |
|
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2009-08-26 : 18:45:41
|
| Thanks everyone for the quick help. It worked :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|