Tuesday, October 25, 2016

Adding days in SQL Server

Hi all,

Here is the function to add number of days to a date.


Oracle
SQL Server
Select sysdate+20 from dual
Select dateadd(day,20,getdate())

Equivalent of ROWNUM of Oracle in SQL Server

Hi all.,

Here is the equivalent of ROWNUM of Oracle in SQL Server





Oracle
SQL Server
Select * from emp where rownum= 1
Select top 1 from emp 

Monday, October 24, 2016

Equivalent of TO_NUMBER of Oracle in SQL Server

Hi all...

Here is the equivalent of TO_NUMBER of Oracle in SQL Server is...



Oracle
SQL Server
Select TO_NUMBER('123') from dual;
Select CONVERT(INT,'123') 
        OR
Select CAST('123' as INT) 

Equivalent of LENGTH of Oracle in SQL Server

Hi All...

The equivalent of LENGTH of Oracle in SQL Server is :



Oracle
SQL Server
Select LENGTH('aweaw') from dual;
Select LEN('aweaw') 

Equivalent of SUBSTR of Oracle in SQL Server

Hi all...


Here is the equivalent of SUBSTR of Oracle in SQL Server will be ..



ORACLE
SQL SERVER
Select 
SUBSTR('TEST_A,TEST_B,TEST_C',1,4) 
from dual;
Select 
SUBSTRING('TEST_A,TEST_B,TEST_C',1,4)
Select 
SUBSTR('TEST_A,TEST_B,TEST_C',1) 
from dual;
Select 
SUBSTRING('TEST_A,TEST_B,TEST_C',1
,LEN('TEST_A,TEST_B,TEST_C'))

Read data from csv in R Programming

Read a data set from csv file.. x <- read.csv(file.choose(),header=TRUE) here x is the R data set vaiable.