This query isn't working what do I do?

I'm trying to run this update statement in SQL 2000 (don't laugh) ;

Update Student set Picture = SID + ‘.jpg’

and I'm receiving the following error:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '‘'.

Do I need parentheses around SID + ‘.jpg’

smantzDirector of TechnologyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee SavidgeCommented:
Maybe a type casting problem or using he wrong quotes.

Update Student set Picture = cast(SID as varchar(100)) + '.jpg'

Open in new window

Failing that, if you need to image name out in a SQL call, make it a derived field so you don't need to store the value twice.
Éric MoreauSenior .Net ConsultantCommented:
what is the datatype of Picture? Of SID?

If SID is numeric, try:
Update Student set Picture = cast(SID as varchar) + ‘.jpg’

Open in new window

trt & instead of +, also check that your quotation marks are not the inverted kind
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Éric MoreauSenior .Net ConsultantCommented:
arana is correct, the first quote is reversed!
smantzDirector of TechnologyAuthor Commented:
Well, I pasted the update from an e-mail a friend sent. The '.jpg' looked the same and in black.  When I actually type the statement into QA the '.jpg' is red. Does this sound correct?

Picture is a (varchar(20),Null)
SID is a (varchar (12), Not Null)
Lee SavidgeCommented:
It's correct if it is red. SQL management studio or query analyser as it was back then, puts string text in red.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lee SavidgeCommented:
If SID is a varchar then no need to cast. It'll be as I said, in that you used the wrong quotes.

update student set picture = SID + '.jpg'

Open in new window

Don't use    ID + ‘.jpg’   but   ID + '.jpg'    -- do you see the apostrophes difference here?

Back apostrophes cannot be used to enclose text literals.

Back apostrophes are used in MySQL to enclose column and table names sometimes.
smantzDirector of TechnologyAuthor Commented:
I used the '  mark located on the key with the " marks before and after the text and it worked.  I did not use the ` mark on the key with the ~.   Typing it in rather than pasting did the trick (that and seeing the red!).  Thanks everyone for such quick responses.


Look at your question:   ‘.jpg’  ...  It does not contain  ' (apostrophe)... But it also does not contain back apostrophe...
It contains left and right single quotation marks... :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.