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)
 Write a query where condition contain apostrophe

Author  Topic 

treeskin
Starting Member

22 Posts

Posted - 2007-11-22 : 20:15:25
Hi,

I would like to know how to write a query where its condition contains apostrophe (')?

Query I wrote which return error:

SELECT bookname, author, publish_date
FROM aLibrary
WHERE bookname = 'AA'S'

Appreciate your sharing. Thanks...

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-11-22 : 21:21:39
need to double up on the single quotes:

SELECT bookname, author, publish_date
FROM aLibrary
WHERE bookname = 'AA''S'

also need to read BOL.




elsasoft.org
Go to Top of Page

treeskin
Starting Member

22 Posts

Posted - 2007-11-22 : 22:37:07
hi jezemine, thanks... it works..

what is BOL? any URL can be provided for more info?
Go to Top of Page

suresha_b
Yak Posting Veteran

82 Posts

Posted - 2007-11-22 : 23:16:17
BOL = Books OnLine.
It is intalled in your computer. URL is not necessary.
Start->All Programs->Microsoft SQL Server 2005->Documents and Tutorials->SQL Server Books Online
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-23 : 02:00:51
To understand the behaviour of single quote, run this and see

select '','''','''''','''''''',''''''''''

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -