如何使用SQL Server使用左emo结束日期从table1更新table2 [英] How do I update table2 from table1 with left emo end date using SQL server

查看:68
本文介绍了如何使用SQL Server使用左emo结束日期从table1更新table2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有table1喜欢dis



文件名,名称,城市

Arun。 TL。 Hyd

Ajay。 JL。 Bang(emp left)



我想输出像



Fulnam,desgntn,city,currentdt,结束日期

Arun。 TL。路政署。 13年1月2日。 Null

Ajay。 JL。 Bang 1/2/15。 Currentdt



我尝试了什么:



我试过teradata



更新table2 set enddate = currentdt where full name ='ajay'

解决方案

我认为必须be:

 更新 table2  set  [  end   date ] = GetDate()其中 [Fulnam] = '  Ajay' 

或更新所有名称:

 更新 table2  set  [结束  date ] = GetDate()
其中 [Fulnam] IN SELECT [文件名] FROM table1)


如果你想要依赖于全名字段的所有行,那么下面的代码可以帮助你解决问题



 UPDATE TABLE2 SET [END DATE] = GETDATE()
FROM TABLE1 A
INNER JOIN TABLE2 B ON A.FILENAME = B .FULNAME


I have table1 like dis

Filename, designation, city
Arun. Tl. Hyd
Ajay. Jl. Bang(emp left)

I want output like dis

Fulnam,desgntn,city,currentdt,end date
Arun. Tl. Hyd. 1/2/13. Null
Ajay. Jl. Bang 1/2/15. Currentdt

What I have tried:

I have tried in teradata

Update table2 set enddate=currentdt where full name='ajay'

解决方案

I think it must be:

Update table2 set [end date]=GetDate() where [Fulnam]='Ajay'

Or to update all names:

Update table2 set [end date]=GetDate() 
where [Fulnam] IN (SELECT [Filename] FROM table1)


If you want to all the rows on depend of the full name field then below code could help u to solve the problem

UPDATE TABLE2 SET [END DATE] = GETDATE()
FROM TABLE1 A
INNER JOIN TABLE2 B ON A.FILENAME =  B.FULNAME


这篇关于如何使用SQL Server使用左emo结束日期从table1更新table2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆