当列大小不同时,将数据从一个表复制到另一个表

时间:2023-01-21 20:08:23

I have two tables t1 (old) with 4 columns and t2 (new table) with 6 columns.

我有两个表t1(旧)有4列和t2(新表)有6列。

I want to copy the data from t1 to t2 with date and 'ÝES' as default values in T2 as these values are not available in T1.

我想将数据从t1复制到t2,日期和'ÝES'作为T2中的默认值,因为这些值在T1中不可用。

  • T1 - 4 columns (c1, c2, c3, c4)
  • T1 - 4列(c1,c2,c3,c4)

  • T2 - 6 columns (c1, c2, c3, c4, getdate(), 'ÝES') like I need
  • T2 - 6列(c1,c2,c3,c4,g​​etdate(),'ÝES')就像我需要的那样

Please help me with this.

请帮我解决一下这个。

1 个解决方案

#1


2  

This should get the desired result:

这应该得到预期的结果:

insert into T2 (c1,c2,c3,c4,c5,c6) select c1,c2,c3,c4,sysdate, 'ÝES' from T1;

#1


2  

This should get the desired result:

这应该得到预期的结果:

insert into T2 (c1,c2,c3,c4,c5,c6) select c1,c2,c3,c4,sysdate, 'ÝES' from T1;