Re: update column failure: Why?
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 11/19/04
- Next message: Steve Kass: "Re: how Can i do this"
- Previous message: Hugo Kornelis: "Re: Help with Date/Time query"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 20 Nov 2004 00:44:29 +0100
On Fri, 19 Nov 2004 17:35:41 -0600, JPM wrote:
>Hi,
>
>SQL 2000
>Attempting to do a mass update to a single column in a table using the
>following sql via the query analyzer.
>
>UPDATE table1
>SET table1.Activity_Flag = Left(table1.Activity_Flag, 1)
>
>The column accepts NULL values and is char(2). The above sql indicates that
>it executes but a check of the data indicates that the space at the end of
>the field is still there. i.e. there are 2 characters in the field
>currently; I want to get rid of the space. What is wrong with this
>elementary sql?
>
>Thanks,
>JPM
Hi JPM,
If the columns is declared as CHAR(2), it is fixed length. The string
stored in it will always be two positions. If you give it just one
position, SQL Server will pad it with a space.
If you need to trim the space, you should use a VARCHAR(2) column. But may
I ask why this extra space is bothering you? There might be other (maybe
even better) ways to achieve what you want to get done.
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Steve Kass: "Re: how Can i do this"
- Previous message: Hugo Kornelis: "Re: Help with Date/Time query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|