smantz
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
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
what is the datatype of Picture? Of SID?
If SID is numeric, try:
If SID is numeric, try:
Update Student set Picture = cast(SID as varchar) + ‘.jpg’
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
arana is correct, the first quote is reversed!
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)
Picture is a (varchar(20),Null)
SID is a (varchar (12), Not Null)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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'
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.
Back apostrophes cannot be used to enclose text literals.
Back apostrophes are used in MySQL to enclose column and table names sometimes.
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
-
--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... :-)
It contains left and right single quotation marks... :-)
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.