This query isn't working what do I do?

smantz
smantz used Ask the Experts™
on
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’

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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 Consultant
Top Expert 2016

Commented:
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
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
arana is correct, the first quote is reversed!
smantzDirector of Technology

Author

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)
It's correct if it is red. SQL management studio or query analyser as it was back then, puts string text in red.
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 Technology

Author

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.

--SM

-
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... :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial