Thursday, June 16, 2011

Oracle(PLSQL) to SQL(T-SQL) server Migration

Currently I am working on Migration Project (oracle to sql),during this project I have faced different syntax issues,  here is some simple example where i showed different  queries in PLSQL and T-SQL.

inshALLAH i will add more queries .
                                 
Oracle
SQL SERVER
SELECT  ‘x’ FROM dual
SELECT ‘x’
SELECT  TRUNC(15.79,1) "Truncate" FROM DUAL;
SELECT ROUND(15.79, 0) rounded , ROUND(15.79,0,1) 
SELECT FLOOR(ROUND(15.79, 0)), FLOOR(ROUND(15.79, 0,1) )
select isnull(anyvalue,0)
select NVL(anyvalue,0) from dual
SELECT to_char(123.45 ,99999999999999) from dual
SELECT to_char(EXPIRY_DATE,'DDMONYYYY') from dual
SELECT STR(123.45, 14)
SELECT STR(round(123.455 , 2),12,2)
SELECT CAST(REPLACE((CONVERT(varchar(12) , EXPIRYDATE, 106 )),' ' , '') as varchar(9))
Select ‘Name’ || ‘Last Name’ From tableName
Select ‘Name’ + ‘Last Name’
SELECT sysdate -add_months(sysdate,12) FROM dual
SELECT  datediff(dd, GetDate(),dateadd(mm,12,getdate()))
Select decode(‘a’,’a’,’write a’)
Case when ‘a’ = ‘a’ then ‘write a’ end

















Click here for Different date formates in oracle and sql server


No comments:

Post a Comment