November 28, 2007 at 1:54 pm
We have been asked to add several symbols to data currently existing in the database for a specific table, in a "name" field column. The data I'm adding has the "registered" and "trademark" symbols associated with the data being added.
However, when I try to cut and past the UPDATE query (with the proper "registered" and "trademark" symbols next to the actual name) into the query analyzer it changes the values to the following:
update grade set grade_name='TRANSCOPYâ' where grade_id='35800';
update grade set grade_name='OPTICAä' where grade_id='35900';
(The 1st update cmd with the â is the "registered" symbol, with a circle around the "R". The 2nd update cmd with the ä is the "trademark" symbol, with the letters TM.)
- The SQL database version is SQL 2005 SP1.
- The database column is VARCHAR(50)
- The current database collation is: SQL_Latin1_General_CP1_CI_AS
What is the proper way to handle data within a column, when one wants to have symbols such as the "trademark" within a database column?
And how can I get this column of data updated with these symbols, so queries and reporting software display these symbols correctly?
Any help would be appreciated...
Dave Gradoville, MCDBA
November 28, 2007 at 2:02 pm
It all depends on your output method and what character sets they support.
November 28, 2007 at 2:04 pm
Antares686 (11/28/2007)
It all depends on your output method and what character sets they support.
As well the font can sometimes give you other than intended results.
November 28, 2007 at 2:09 pm
ANT,
Are you saying that the update cmd actually works properly, and the data is correctly updated with the appropriate symbol? If so, if a user has permissions to query the data in the column -- how does he/she tell what symbol is associated with the data?
:unsure:
Dave Gradoville, MCDBA
November 28, 2007 at 2:33 pm
This should do it...
UPDATE Grade
SET Grade_Name = CASE
WHEN Grade_ID = '35800'
THEN 'TRANSCOPY' + CHAR(153) --™
WHEN Grade_ID = '35900'
THEN 'OPTICA' + CHAR(174) --®
WHERE Grade_ID IN ('35800','35900')
--Jeff Moden
Change is inevitable... Change for the better is not.
November 28, 2007 at 2:35 pm
That is the problem the character set you must have gotten it out of was symbol so if on a web page you display it it might look like this
[font="arial"]TRANSCOPYâ[/font]
when you want it to look like this
[font="arial"]TRANSCOPY[/font][font="symbol"]â[/font]
which looks right but I have to set the font for viewing myself. But if I made the whole line font = symbol it would look like this
[font="symbol"]TRANSCOPYâ[/font]
Some fonts have common support for registered like arial but the value is different
[font="arial"]TRANSCOPY®[/font]
and tahoma
[font="tahoma"]TRANSCOPY®[/font]
but would look like this in symobl
[font="arial"]TRANSCOPY[/font][font="symbol"]®[/font]
But I couldn't find a common one for Trademark.
November 28, 2007 at 2:36 pm
By the way... your code seems to indicate that the Grade_ID is stored as a VARCHAR. If it's trully a numeric throughout, you may want consider changing the datatype to INT to keep people from entering anything but digits. Saves a bit of storage space, too.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 28, 2007 at 2:39 pm
Jeff Moden (11/28/2007)
This should do it...
UPDATE Grade
SET Grade_Name = CASE
WHEN Grade_ID = '35800'
THEN 'TRANSCOPY' + CHAR(153) --™
WHEN Grade_ID = '35900'
THEN 'OPTICA' + CHAR(174) --®
WHERE Grade_ID IN ('35800','35900')
Thanks Jeff I couldn't find it off the top of my head. But like I stated these show in most common fonts as the expected but say you used the font Symbol they would not look right. The only absolute way to ensure you always get the expected look is to use an image file otherwise but Jeff's should cover 99% of the cases of anyone looking.
November 28, 2007 at 2:49 pm
Thank you two (Jeff and ANT) very much - i really appreciate your time and effort!
Dave Gradoville, MCDBA
November 28, 2007 at 2:53 pm
gradpks ,
You can view any of the character codes in charmap. To view charmap click --> start --> run --> charmap and get the proper key strokes or code to create each symbol. From here you can use the Char(###) function or you can actually perform the keystroke and put the char in single quotes.
example Alt + 0169 = © then put it into single quotes for the update. E.g.
UPDATE TABLE
SET Col = 'String' + '©'
WHERE some filter
November 28, 2007 at 3:00 pm
Similar thing can be done in SQL Server...
SELECT Number AS CharNum, CHAR(Number) AS Character
FROM Master.dbo.spt_Values
WHERE Type = 'P'
AND Number < 256
--Jeff Moden
Change is inevitable... Change for the better is not.
November 28, 2007 at 3:11 pm
Sweet :hehe: I did not know about this, thanks Jeff !!
November 28, 2007 at 8:58 pm
Heh... your welcome...
spt_values table is the "original" Tally table... it goes from 0 to 255 in 2k and I think it goes to 1023 or 1024 in 2k5.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply