l******9 发帖数: 579 | 1 On SQL Server 2008 R2, I need to add some columns into a table from another
table.
e.g.
Table1:
name value id
Jim 288 abf
Table 2:
name acct num rank
Jim 12 29 8
Jim 98 95 7
Jim 20 52 9
What I need:
name value id acct num rank acct num rank acct num rank
Jim 288 abf 12 29 8 98 95 7 20 52 9
The record numbers in table 2 may be variable.
Any help would be appreciate. |
d****i 发帖数: 4809 | 2 I guess you really want to have full join on two tables:
SELECT t1.name, t1.value, t1.id, t2.acct, t2.num, t2.rank FROM Table1 AS t1
FULL JOIN Table2 AS t2 ON t1.name=t2.name
another
【在 l******9 的大作中提到】 : On SQL Server 2008 R2, I need to add some columns into a table from another : table. : e.g. : Table1: : name value id : Jim 288 abf : Table 2: : name acct num rank : Jim 12 29 8 : Jim 98 95 7
|
n*w 发帖数: 3393 | 3 what of there are 1000000 rows for Jim in table 2?
use row number to generate sequence number then pivot
another
【在 l******9 的大作中提到】 : On SQL Server 2008 R2, I need to add some columns into a table from another : table. : e.g. : Table1: : name value id : Jim 288 abf : Table 2: : name acct num rank : Jim 12 29 8 : Jim 98 95 7
|
n*****t 发帖数: 22014 | 4 SP 可以做,不过为什么要这么设计?一定要做为什么不在 app 里?
another
【在 l******9 的大作中提到】 : On SQL Server 2008 R2, I need to add some columns into a table from another : table. : e.g. : Table1: : name value id : Jim 288 abf : Table 2: : name acct num rank : Jim 12 29 8 : Jim 98 95 7
|