Home All Groups Group Topic Archive Search About
Author
4 Nov 2005 1:23 PM
tonyp
Hi.  I have an issue with an SQL 2000 database.  I have a column that I
need to copy to another column within the same table.  There are already
values in the destination column and I want to append the new values to the
end of the existing data within each field.
     I am an experienced net admin but very little coding experience.  I'm
wondering if someone can point me in the right direction?

Author
4 Nov 2005 1:33 PM
Cowboy (Gregory A. Beamer)
UPDATE MyTable SET Column1 = Column1 + Column2

If you are dealing with potential nulls

UPDATE MyTable SET Column1 = CASE
                    WHEN Column1 IS NULL THEN Column2
                     ELSE Column1 + Column2 END
WHERE Column2 IS NOT NULL

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think Outside the Box!
***********************************************
Show quote
"tonyp" <to***@discussions.microsoft.com> wrote in message
news:696E1F08-57E7-4F57-B45C-14D4C1A68447@microsoft.com...
>     Hi.  I have an issue with an SQL 2000 database.  I have a column that
> I
> need to copy to another column within the same table.  There are already
> values in the destination column and I want to append the new values to
> the
> end of the existing data within each field.
>     I am an experienced net admin but very little coding experience.  I'm
> wondering if someone can point me in the right direction?
Author
4 Nov 2005 2:07 PM
tonyp
Thank you for your response.  I might add that these are both text fields,
not numeric.

Show quote
"Cowboy (Gregory A. Beamer)" wrote:

> UPDATE MyTable SET Column1 = Column1 + Column2
>
> If you are dealing with potential nulls
>
> UPDATE MyTable SET Column1 = CASE
>                     WHEN Column1 IS NULL THEN Column2
>                      ELSE Column1 + Column2 END
> WHERE Column2 IS NOT NULL
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***********************************************
> Think Outside the Box!
> ***********************************************
> "tonyp" <to***@discussions.microsoft.com> wrote in message
> news:696E1F08-57E7-4F57-B45C-14D4C1A68447@microsoft.com...
> >     Hi.  I have an issue with an SQL 2000 database.  I have a column that
> > I
> > need to copy to another column within the same table.  There are already
> > values in the destination column and I want to append the new values to
> > the
> > end of the existing data within each field.
> >     I am an experienced net admin but very little coding experience.  I'm
> > wondering if someone can point me in the right direction?
>
>
>

AddThis Social Bookmark Button