Link to home
Start Free TrialLog in
Avatar of smantz
smantzFlag for United States of America

asked on

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’

Thanks
Avatar of Lee
Lee
Flag of United Kingdom of Great Britain and Northern Ireland image

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

SOLUTION
Avatar of Arana (G.P.)
Arana (G.P.)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
arana is correct, the first quote is reversed!
Avatar of smantz

ASKER

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)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of smantz

ASKER

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