Update a column to an EMPTY STRING not working

  • .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?

     

    BT
  • COL_1 CHAR(1) will padd your string to ' '

    so if you wanna store '' than use VARCHAR(1) or treat ' ' like an empty string


    Kindest Regards,

    Vasc

  • Or use nulls if you don't know what to put there.

  • 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

  • well, the .Net developer replied that he is going to TRIM the column.

    Works for me.  (thx folks!)

    BT
  • I feel I must restate this :

    trim (char(' ')) = ' '

  • 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