select a.KaHao,b.mingma from Tbl_checkIn a,tbl_ShouPiao b where a.KaHao=b.kahao and CheckInTime between '2010-9-17' and '2010-9-20' and mingma>='1214' and mingma<='1218'
各位高手,上面是多表查询写的语句,然后查出来结果想要修改日期为9月30日,如上图的日期格式,下面语句CheckInTime的写法对吗?update a set CheckInTime='2010-9-30' from Tbl_checkIn a,tbl_ShouPiao b where a.KaHao=b.kahao and CheckInTime between '2010-9-17' and '2010-9-20' and mingma>='1214' and mingma<='1218'
各位高手,上面是多表查询写的语句,然后查出来结果想要修改日期为9月30日,如上图的日期格式,下面语句CheckInTime的写法对吗?update a set CheckInTime='2010-9-30' from Tbl_checkIn a,tbl_ShouPiao b where a.KaHao=b.kahao and CheckInTime between '2010-9-17' and '2010-9-20' and mingma>='1214' and mingma<='1218'
解决方案 »
- 求一条Sql 语句(从一个表查询数据添加到另外两个表)
- 自定义函数中能否使用数据库名作为参数?
- 请问是否在SQL SERVER中某列建立索引后,当查询时,SQL SERVER会自动运用索引
- 为什么我得MSSQL2000数据库用本地服务器名可以连接数据库,用IP地址却不能连接数据库了呢???
- 请教如何在视图中增加一个ID列?
- SQL Server 卸载后无法在安装具体症状如下
- sql server2008标准版完整备份问题
- 每个月查的数据有的。如何变成1到12月份数据提取。。。(请教高手)
- 讨论!日期字段问题。
- 配置发布服务器问题,在线等待!!
- excel导入到数据库(access、mssql)导出,请帮忙指点。
- sqlServer2000时间datetime字段修改问题?
----
修改日期为9月30日,按我的理解就不对,仅仅是改日期,并不需要改时间,而上面的语句将所有的时间打到0点。
from Tbl_checkIn a,tbl_ShouPiao b where a.KaHao=b.kahao and CheckInTime between '2010-9-17' and '2010-9-20' and mingma>='1214' and mingma<='1218'
SET CheckInTime='2010-9-30'
FROM Tbl_checkIn a,tbl_ShouPiao b
where a.KaHao=b.kahao
and CheckInTime between '2010-9-17' and '2010-9-20'
and mingma>='1214' and mingma<='1218'
with update_test as
(
select a.KaHao,b.mingma,CheckInTime,
newtime=(datetime,'2010-09-30+convert(char(12),CheckInTime,114),120)
from Tbl_checkIn a
inner join tbl_ShouPiao b
on a.KaHao=b.kahao
where CheckInTime between '2010-9-17'
and '2010-9-20' and mingma>='1214' and mingma<='1218';
)
update update_test
set CheckInTime =newtime;
with update_test as
(
select a.KaHao,b.mingma,CheckInTime,
newtime=(datetime,'2010-09-30'+convert(char(12),CheckInTime,114),120)
from Tbl_checkIn a
inner join tbl_ShouPiao b
on a.KaHao=b.kahao
where CheckInTime between '2010-9-17'
and '2010-9-20' and mingma>='1214' and mingma<='1218';
)
update update_test
set CheckInTime =newtime;
with update_test as
(
select a.KaHao,b.mingma,CheckInTime,
newtime=convert(datetime,'2010-09-30'+convert(char(12),CheckInTime,114),120)
from Tbl_checkIn a
inner join tbl_ShouPiao b
on a.KaHao=b.kahao
where CheckInTime between '2010-9-17'
and '2010-9-20' and mingma>='1214' and mingma<='1218';
)
update update_test
set CheckInTime =newtime;
--不好意思 让大家看笑话了 呵呵