MySql向SQLServer遷移常見問題
阿新 • • 發佈:2018-12-07
-- MySql與SQLServer update inner join語法區別
-- MySql:
UPDATE A
LEFT JOIN B ON A.B_ID = B.B_ID
SET
A.A_NAME = B.B_NAME;
-- SQLserver:
update A
set A_NAME = B.B_NAME
from A
left join B ON A.B_ID = B.B_ID;
-- MySql與SQLServer update inner join語法區別
-- order by 排序 as (NUM) 固定;
ROW_NUMBER() OVER (order by SORT_CODE ASC,ID DESC) as NUM
-- MySql DATE_FORMAT() 函式 改為 CONVERT()
-- 例: CREATE_TIME
DATE_FORMAT(CREATE_TIME, '%Y-%m-%d %H:%i:%s') CREATE_TIME
-- To
CONVERT(varchar(100), CREATE_TIME, 20) CREATE_TIME
--SQLServer
sum(case when A>0 then A else 0 end ) as 'A正'
--Mysql
sum(IF(bdi.SIGN_STATUS > 0, 1, 0)) AS QSJS
--SQLServer 查詢的所有欄位都需要group by
目前只總結了這些,後期遇見了再補充