oracle和sqlserver不同
--------------------------------------------
1.case when
eg:
oracle:
SELECT (
CASE WHEN Org_type= 1 THEN ( SELECT Name1 FROM Company_Master WHERE Org_ID =1 )
WHEN Org_type= 2 THEN ( SELECT Name1 FROM Company_Master WHERE Org_ID =1 )
WHEN Org_type= 3 THEN ( SELECT Name1 FROM Company_Master WHERE Org_ID =1 )
ELSE to_nchar('1') END
) AS Name1
FROM Organization_Master WHERE Org_ID = 1
sql server:
SELECT (
CASE WHEN Org_type= 1 THEN ( SELECT Name1 FROM Company_Master WHERE Org_ID =1 )
WHEN Org_type= 2 THEN ( SELECT Name1 FROM Company_Master WHERE Org_ID =1 )
WHEN Org_type= 3 THEN ( SELECT Name1 FROM Company_Master WHERE Org_ID =1 )
ELSE '1' END
) AS [Name1]
FROM Organization_Master WHERE Org_ID = 1
区别:1.在oracle里面如果THEN后边的类型和ELSE后面的类型不一致,需要用函数转化(具体用什么函数,要根据具体情况而定,比如to_char和to_nchar等)比如: to_nchar('1'), 在 sqlserver中则不需要
2.在oracle中AS后边的列名不用加任何符号如:AS Name1,在sqlserver中需要用AS [Name1]
------------------------------------------------------
2.top 不同
oracle
select * from User_Master where rownum<=10
sqlserver
select top 10* from User_Master
区别:注:oracle里面不支持top只能变成where条件语句