Monday 5 March 2018

How to store decimal values in SQL Server?

 Syntax:
DECIMAL(n,m);
where  n is the total number of  digits and
m is the max number of digits you can have after the decimal point.
Example:
salary decimal(7,2);
   
Commands:
// Create Database
 Create Database LP;   

 //Select Database
  Use LP;          
               
//Create table DPK
Create table DPK (Employee_ID INT Not NULL,Employee_Name Varchar (20)NOT NULL, Salary decimal(7,2) NOT NULL ,PRIMARY KEY (Employee_ID));    
//Retrieve  Data from DPK
Select * from DPK;
//Insert Data into DPK
INSERT into DPK(Employee_ID, Employee_Name,Salary) values (101, 'Ram Kumar',89555.78 );
INSERT into DPK(Employee_ID, Employee_Name,Salary) values (102, 'suryosnata',55000.79);
 INSERT into DPK(Employee_ID, Employee_Name,Salary) values (103, 'Dipak',90000.58 );

//Retrieve  Data from DPK
Select * from DPK;



No comments:

Post a Comment

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...