August 31, 2005 at 12:48 pm
.Net Developer asked me to run this UPDATE on a column; he wants the column set to an EMPTY STRING:
UPDATE tbl_a SET col_1 = ''
Column definition: COL_1 CHAR(1) NOT NULL
Says his code is not functioning properly. SQL 2000 SP4 w/ Compatibility on this DB set to 80.
Does this column datatype need to be STRING?
Any ideas regarding this UPDATE statement?
August 31, 2005 at 1:07 pm
COL_1 CHAR(1) will padd your string to ' '
so if you wanna store '' than use VARCHAR(1) or treat ' ' like an empty string
Vasc
August 31, 2005 at 1:07 pm
Or use nulls if you don't know what to put there.
August 31, 2005 at 1:35 pm
Ok here goes.
1. '' = empty string, NULL is the ABSENCE of everything and is generally NOT a good idea to use. (There are REAMS of documentation on both fronts... Consider this a personal opinion).
2. What is the code NOT doing properly? Without that critical piece (and could quite honestly be CODING problem) we really can't help....
Good Hunting!
AJ Ahrens
webmaster@kritter.net
August 31, 2005 at 1:40 pm
well, the .Net developer replied that he is going to TRIM the column.
Works for me. (thx folks!)
August 31, 2005 at 1:42 pm
I feel I must restate this :
trim (char(' ')) = ' '
September 1, 2005 at 5:59 pm
It will trim just fine as long as the developer does it in a program (not in SQL).
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply