sqlserver 常用语句

1、多表语句更新

UPDATE B

SET B.loginname=c.loginname
FROM t_employee A, t_systemuser B, oa_employee c
WHERE  A.employeeid=B.belonguserid AND A.oaemployeeid = c.id
 
2、SELECT  CONVERT(VARCHAR(500),PropertyID)+',' FROM Table WHERE RecordStatus='Active' FOR XML PATH('')
3、行转列

select * from DailyIncome ----第一步
pivot
(
sum (IncomeAmount) ----第三步
for IncomeDay in ([MON],[TUE],[WED],[THU],[FRI],[SAT],[SUN]) ---第二步
) as AvgIncomePerDay

 
posted @ 2019-03-28 16:00  yjge  阅读(164)  评论(0编辑  收藏  举报