Hi. I need to insert a semicolon into one of my fields in a sql server 2000 database. I have a height column and i was trying to insert height. i know i can't insert 4'5" b/c of the apostrophe and double quote, so i was trying to insert it like: 4'7"now i'm running into a problem with the semicolons. how can i insert the semicolons? thanks!
edit:
aparently this is removing the same things: here's what i'm talking about:
http://www.thoughtreactor.com/img-0009.pnginsert into theTable (theColumn) values (';');
Where is the problem?|||Hi. I need to insert a semicolon into one of my fields in a sql server 2000 database. I have a height column and i was trying to insert height. i know i can't insert 4'5" b/c of the apostrophe and double quote, so i was trying to insert it like: 4'7"now i'm running into a problem with the semicolons. how can i insert the semicolons? thanks!
edit:
aparently this is removing the same things: here's what i'm talking about:
http://www.thoughtreactor.com/img-0009.png
Read up on escape characters in BOL.
create table #specialk (colid int identity, char_desc varchar(20), special_char varchar(10))
insert into #specialk (char_desc, special_char)
SELECT 'APOSTROPHE', ''''
UNION
SELECT 'QUOTE', '"'
UNION
SELECT 'SEMICOLON', ';'
UNION
SELECT 'Height', '4'' 7"'
SELECT * FROM #specialk order by colid
drop table #specialk
-- OUTPUT
colid char_desc special_char
---- ------- ----
1 APOSTROPHE '
2 Height 4' 7"
3 QUOTE "
4 SEMICOLON ;
(4 row(s) affected)|||i have a dropdown menu where the user selects the height. it looks like the picture i posted above. whenever it inputs the value, it says i have an error and it's near the semicolon.|||It looks like you are not inserting the data with escape characters ... go read and play with escape characters.
I've pointed you toward a solution - I'm not going to solve it for you.
I'm showing you how to fish ... not filleting it for you.|||It looks like you are not inserting the data with escape characters ... go read and play with escape characters.
I've pointed you toward a solution - I'm not going to solve it for you.
I'm showing you how to fish ... not filleting it for you.
well, i fiddled with it for a little while and had no luck so I decided to take the step and re-normalize my database and just have a separate table for the height description. but thank you for pointing me in the right direction!|||also, it might make sense for you to store height in inches only, in an int column, rather than a combination of feet and inches in a char column. Then you could easily do things like sort by height, etc.
your client app could easily convert the number 65 to 5' 5" if that's the requirement.
using a character type to store what's really a number is a bad design.|||also, it might make sense for you to store height in inches only, in an int column, rather than a combination of feet and inches in a char column. Then you could easily do things like sort by height, etc.
your client app could easily convert the number 65 to 5' 5" if that's the requirement.
using a character type to store what's really a number is a bad design.
that's exactly what i did. at first i started out with 4'7" but i thought what if we wanted to find the average height of people? so i decided to put it in inches. thanks for your help though!|||Well then you wouldn't be storing "display" data.
Either, store the height in decimal form, or use 2 columns, 1 for feet and one for inches|||I would never use two columns for the same measure, in this case a length. sorting would not work at all if someone puts 0 for the feet and 100 for the inches...
if 2 columns is good, why not 4 columns? one for hands, one for furlongs, one for fathoms, one for millimeters?
use one column, and make it a number. fine to use a decimal if you care about fractions of inches. here's a tip: include the units in the name of the column so it's crystal clear: HeightInches|||It's all about using parameterised queries/statements in your client. I'd read up on that even in preference to escape characters which you rarely need to bother with.
FWIW I agree that you should be storing inches only. Is 4'7" really less than 6"? It is if you store it as a varchar and order by height.
Personally I'd use cm ;)|||Personally I'd use cm
Me as well, or mm if it should be accurate
Showing posts with label semicolon. Show all posts
Showing posts with label semicolon. Show all posts
Subscribe to:
Posts (Atom)