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 first published in October 2003

Dig deeper on Oracle and SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

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.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close