Q

Quotes in SQL

Question 1:

I am currently reading Transact-SQL by Bennett McEwan. I was trying to do a query on the pubs test database...

select "Hello, my name is ", fname
from employee

No matter how I word the query it keeps bombing out and saying...

Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'hello, my name is'.

Is the command structure for "Constant Strings" different for SQL 2000?

Question 2:

Let's say I have a table named "STAFF". One of the fields is "NAME". Now, if I have a staff name "Mohd Ja'far" then how can I retrieve this data using SQL. The query:

SELECT * FROM STAFF 
WHERE NAME LIKE '%Ja'fa%'

is not working because the ' in the name.

This was last published in October 2003

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close