Posted by imani_technology_spam@yahoo.com on 09/26/05 22:26
Let's say I have two tables:
CREATE TABLE dbo.OldTable
(
OldID int NOT NULL,
OldNote varchar(100) NULL
) ON [PRIMARY]
GO
AND
CREATE TABLE dbo.NewTable
(
NewID int NOT NULL IDENTITY (1, 1),
OldID int NULL,
ComboNote varchar(255) NULL
) ON [PRIMARY]
GO
ALTER TABLE dbo.NewTable ADD CONSTRAINT
PK_NewTable PRIMARY KEY CLUSTERED
(
NewID
) ON [PRIMARY]
GO
OldTable's data looks like this:
OldID OldNote
----- -------
1 aaa
2 bbb
3 ccc
2 ddd
4 eee
NewTable's data (which is derived from the OldTable) should look like
this:
NewID OldID ComboNote
----- ----- ---------
1 1 aaa
2 2 bbb + char(13) + ddd
3 3 ccc
4 4 ddd
How can I combine the notes from OldTable where two (or more) records
have the same OldID into the NewTable's ComboNote?
[Back to original message]
|