Table A's data (FileNo, Data) is
1, 'Test'
Table B's data (FileNo, Data) is
1, ',First Test'
1, ',Second Test'
1, ',Third Test'
I want to end up with Table A's Data field containing 'Test,First
Test,Second Test,Third Test'
In Access SQL, the following would do it:
UPDATE [Table A] INNER JOIN [Table B] ON [Table A].FileNo = [Table B].FileNo
SET [Table A].Data = [Table A].[Data] & [Table B].[Data];
In T-SQL, I can (apparently) only use a single table in the Update clause.
When I tried the following:
update [Table A]
Set [Table A].Data = a.Data + b.Data
from [Table A] a inner join [Table B] b
on a.FileNo = b.FileNo
I end up with [Table A].data containing 'Test,First Test'. This is not too
surprizing since Table A has only one row, but is there a way to accomplish
what I want in T-SQL?
Thanks for any advice.
Jay
It may not be the only way to do it, but I think it should work. This will
also take into account if Table B has varying number of records for each
FileNum.
Lee Mychajluk
Wertheim Inc.
"Jay Dougherty" <jaydou...@worldnet.att.net> wrote in message
news:Fkzp7.24633$Uf1.2...@bgtnsc06-news.ops.worldnet.att.net...
If you'd post DDL, we would know what the keys are, instead guessing
at it.
CREATE TABLE A
(file_nbr INTEGER NOT NULL PRIMARY KEY,
data CHAR(10) NOT NULL);
CREATE TABLE B
(file_nbr INTEGER NOT NULL,
data CHAR(10) NOT NULL,
PRIMARY KEY (file_nbr, data));
>> I want to end up with Table A's Data field containing 'Test,First
Test,Second Test,Third Test' <<
Don't do this -- get a book and read about First Normal Form.
>> In Access SQL, the following would do it:
UPDATE [Table A] INNER JOIN [Table B] ON [Table A].FileNo = [Table
B].FileNo
SET [Table A].Data = [Table A].[Data] & [Table B].[Data]; <<
In SQL, this means that you are updating the result of the INNER JOIN;
that working table disappears at the end of the statement. Kinda
useless, unh?
ACCESS is not SQL -- not even close! It will take about a year to
un-learn it.
If you reallllly, realllly want to scew up your database, we can tell
you how to use a scalar subquery and cross joins to do this. But it
is like asking what is the best kind of rock to use to drive screws
into fine furniture.