Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating string field with values that have quotations

Status
Not open for further replies.

Luvsql

Technical User
Apr 3, 2003
1,179
CA
I need to run an update statement but the text value has an " in it to depict inches.

UPDATE EQUIPMENT SET DESCRIPTION='PIPE WALLSPREADER FOR 1 1/2" (ID) WHERE CODE='ALLHA0009'

This yields an error "Unclosed quotation mark after the character string ''."

What syntax do I use in order to update text with "?
 
You should have a closing single quote after (ID):
Code:
UPDATE EQUIPMENT 
      SET DESCRIPTION='PIPE WALLSPREADER FOR 1 1/2" (ID)[COLOR=red][b]'[/b][/color]
WHERE CODE='ALLHA0009'


Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Missing a closeing single quote...

UPDATE EQUIPMENT
SET DESCRIPTION='PIPE WALLSPREADER FOR 1 1/2" (ID)'
WHERE CODE='ALLHA0009'

Simi
 
UPDATE EQUIPMENT
SET DESCRIPTION='20' X 20' - GOLD LAMÉ'
WHERE CODE='BUTTE0670'

This yields "Incorrect syntax near 'X'."

I have a single quotation within the description to describe 'feet.'
 
You need to double up your single-quotes when the single-quote is part of the data and not a string delimiter.

Code:
UPDATE EQUIPMENT 
SET DESCRIPTION='20[!]''[/!] X 20[!]''[/!] - GOLD LAMÉ' 
WHERE CODE='BUTTE0670'

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top