insert into 表(col1,col2.....自增字段不要加入)
select col1,col2..,dateadd(month,1,日期字段),...自增字段不要加入 from 表 where convert(char(7),日期字段,120)='2003-08'对应的日期字段作一下处理,如上
select col1,col2..,dateadd(month,1,日期字段),...自增字段不要加入 from 表 where convert(char(7),日期字段,120)='2003-08'对应的日期字段作一下处理,如上
where datediff(day,日期字段,'20030815') = 0update #tt set 日期字段 = '20030915'insert into yourtable
select * from #tt
ok
有个问题,用insert selectfrom命令好象不能是两个相同名字的 表啊
我的代码该怎么写呢
是insert into gongzi.姓名,gongzi。基础工资,gongzi。月份 select 姓名,基础工资,月份 from gongzi where 月份=8
还是insert into 姓名,基础工资,月份 select 姓名,基础工资,月份 from gongzi where 月份=8呢
insert into gongzi select 姓名,基础工资,2003-8-15 from gongzi where 月份=2003-9-15,得到的结果应该是将原来月份中的2003-9-15替换为2003-8-15保存到数据库中,但发现在数据库中新插入记录的月份字段的值变成了1905-6-4了,这是怎么回事呢,有谁知道吗?
insert into gongzi select 姓名,基础工资,'2003-9-15' from gongzi where 月份=8 and 年份=2003