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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Single quote

Author  Topic 

zhshqzyc
Posting Yak Master

240 Posts

Posted - 2008-08-18 : 11:42:39
Can you please look at my query?
Select TOP 10 ID,DESCR FROM TABLEA
WHERE DESCR like "~KeyWord~+'%'"

~KeyWord~ is an input variable in my xml file.
I think it is wrong here.
Maybe ''_KeyWord~'+'%''??

I can't obtain the right results.


I want to make it as
WHERE DESCR like 'CPU%'
or

WHERE DESCR like 'TV%'

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 11:44:55
what's this db? is it sql server? in sql server variables are refered using @ so the above query will be
Select TOP 10 ID,DESCR FROM TABLEA
WHERE DESCR like @KeyWord +'%'
Go to Top of Page

zhshqzyc
Posting Yak Master

240 Posts

Posted - 2008-08-18 : 11:59:36
Well.
Let me say in this way.

Suppose I set the condition as
WHERE DESCR LIKE'CPU%'

Can I replace it with
''CPU' + '%''

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 13:49:40
yup you can with slight change. its not " but '

WHERE DESCR LIKE 'CPU' + '%'
Go to Top of Page
   

- Advertisement -