Saturday, June 16, 2018
Friday, November 17, 2017
Tuesday, April 4, 2017
Program for Student Log time calculation..
Hi All,
Today we are going to discuss about the log hours in a school ,
Create table std_logs
(
SID NUMBER,
IN_TIME DATE,
OUT_TIME DATE
);
/
create or replace PROCEDURE std_log_time
(
P_STD_ID NUMBER
)
AS
v_count_sid number(10) := 0;
v_sid NUMBER;
v_in_time DATE;
v_out_time DATE;
V_RN NUMBER(10);
BEGIN
SELECT count(SID) INTO v_count_sid FROM std_logs WHERE SID = p_std_id ;
IF (v_count_sid >0 ) THEN
SELECT A.rn,A.in_time INTO v_rn,v_in_time
FROM (SELECT ROWNUM rn,in_time
FROM std_logs
WHERE SID= p_std_id
ORDER BY in_time DESC ) A
WHERE A.rn =1;
IF ((to_number(to_char(SYSDATE,'dd')) = to_number(to_char(v_in_time,'dd'))) and (to_number(to_char(SYSDATE,'mm')) = to_number(to_char(v_in_time,'mm'))) and (to_number(to_char(SYSDATE,'yyyy')) = to_number(to_char(v_in_time,'yyyy')))) THEN
--INSERT INTO std_logs VALUES(p_std_id,SYSDATE,NULL);
UPDATE std_logs SET out_time = SYSDATE WHERE SID = p_std_id;
ELSE
INSERT INTO std_logs VALUES(p_std_id,SYSDATE,NULL);
END IF;
ELSE
INSERT INTO std_logs VALUES(p_std_id,SYSDATE,NULL);
end if;
END;
/
This is how the student information is going to be captured by the Biometric systems.
EXECUTE std_log_time(999);
SELECT s.*,floor((s.out_time-s.in_time)*24)||'Hrs,'
||floor(((s.out_time-s.in_time)*24 - floor((s.out_time-s.in_time)*24))*60)||'Mins.' diff_time
FROM std_logs s;
Today we are going to discuss about the log hours in a school ,
Create table std_logs
(
SID NUMBER,
IN_TIME DATE,
OUT_TIME DATE
);
/
create or replace PROCEDURE std_log_time
(
P_STD_ID NUMBER
)
AS
v_count_sid number(10) := 0;
v_sid NUMBER;
v_in_time DATE;
v_out_time DATE;
V_RN NUMBER(10);
BEGIN
SELECT count(SID) INTO v_count_sid FROM std_logs WHERE SID = p_std_id ;
IF (v_count_sid >0 ) THEN
SELECT A.rn,A.in_time INTO v_rn,v_in_time
FROM (SELECT ROWNUM rn,in_time
FROM std_logs
WHERE SID= p_std_id
ORDER BY in_time DESC ) A
WHERE A.rn =1;
IF ((to_number(to_char(SYSDATE,'dd')) = to_number(to_char(v_in_time,'dd'))) and (to_number(to_char(SYSDATE,'mm')) = to_number(to_char(v_in_time,'mm'))) and (to_number(to_char(SYSDATE,'yyyy')) = to_number(to_char(v_in_time,'yyyy')))) THEN
--INSERT INTO std_logs VALUES(p_std_id,SYSDATE,NULL);
UPDATE std_logs SET out_time = SYSDATE WHERE SID = p_std_id;
ELSE
INSERT INTO std_logs VALUES(p_std_id,SYSDATE,NULL);
END IF;
ELSE
INSERT INTO std_logs VALUES(p_std_id,SYSDATE,NULL);
end if;
END;
/
This is how the student information is going to be captured by the Biometric systems.
EXECUTE std_log_time(999);
SELECT s.*,floor((s.out_time-s.in_time)*24)||'Hrs,'
||floor(((s.out_time-s.in_time)*24 - floor((s.out_time-s.in_time)*24))*60)||'Mins.' diff_time
FROM std_logs s;
Thursday, February 2, 2017
Wednesday, February 1, 2017
Tuesday, November 29, 2016
CHILD_RECORD_FOUND Equivalent in SQL Server
HI All..,,
for CHILD_RECORD_FOUND in Oracle , in SQL Server is Error_number = 547
begin try
---------
----------
end try
begin catch
if @errornumber = 547
print 'Unable to delete Parent , as child record exists'
end catch
for 547 ===> delete statement conflicted with the reference constraint
for CHILD_RECORD_FOUND in Oracle , in SQL Server is Error_number = 547
begin try
---------
----------
end try
begin catch
if @errornumber = 547
print 'Unable to delete Parent , as child record exists'
end catch
for 547 ===> delete statement conflicted with the reference constraint
Wednesday, November 23, 2016
Monday, November 21, 2016
Extract Time from given Date in SQL Server
Hi guys,
To extract the exact time from from given date as shown below:
Select cast(getdate() as time) [time]
To extract the exact time from from given date as shown below:
Select cast(getdate() as time) [time]
Thursday, November 17, 2016
How to search a word contains procedure in SQL Server...
SELECT *
FROM sys.sql_modules m
INNER JOIN
sys.objects o
ON m.object_id = o.object_id
WHERE m.definition Like '%test%';
Tuesday, November 15, 2016
RAISEERROR in SQL Server......
declare @ErrorMessage varchar(1000) = error_message()
declare @ErrorSeverity int =error_severity()
declare @ErrorState int = error_state()
RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
);
Previous Month First day in SQL Server
Previous Month First day...
CONVERT(DATETIME, CONVERT(VARCHAR(7), dateadd(m,-1,GETDATE()), 120) + '-01')
Wednesday, November 9, 2016
Extract Day, Month, Year from date
Hi guys..,
Oracle
|
SQL Server
|
SELECT to_char(sysdate,'dd') FROM DUAL;
|
select day(getdate())
|
SELECT to_char(sysdate,'mm') FROM DUAL;
|
select month(getdate())
|
SELECT to_char(sysdate,'yyyy') FROM DUAL;
|
select year(getdate())
|
Friday, November 4, 2016
Oracle's Median in SQL Server
Hi All...,
Here is the equivalent function for Oracle's Median in SQL Server..
Here is the equivalent function for Oracle's Median in SQL Server..
Oracle
|
SQL Server
|
select deptno,median(sal) from emp group by deptno
|
select * from
(select distinct e.deptno, PERCENTILE_CONT(0.5)
within group(order by e.sal) over(partition by e.deptno)
as median_sal from emp e)
as a
where a.deptno is not null
|
TRUNC on DATE in Oracle to SQL SERVER
Hi all ..,
Here is the date formats, conversions to SQL Server..
Here is the date formats, conversions to SQL Server..
Oracle
|
SQL Server
|
SELECT TRUNC(SYSDATE) FROM dual;
|
CONVERT(DATETIME, CONVERT(DATE, GETDATE()))
|
Select TRUNC(SYSDATE, 'MM') from dual;
|
Select CONVERT(DATETIME, CONVERT(VARCHAR(7), GETDATE(), 120) + '-01')
|
Select TRUNC(SYSDATE, 'MONTH') from dual;
|
Select CONVERT(DATETIME, CONVERT(VARCHAR(7), GETDATE(), 120) + '-01')
|
SELECT TRUNC(SYSDATE, 'YY') FROM dual;
|
SELECT CONVERT(DATETIME, CONVERT(VARCHAR(4), GETDATE(), 120) + '-01-01');
|
Subscribe to:
Posts (Atom)
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.
-
SELECT * FROM sys.sql_modules m INNER JOIN sys.objects o ON m.object_id = o.object_id WHERE m.definition Like ...
-
Hi all., Here is the equivalent of ROWNUM of Oracle in SQL Server Oracle SQL Server Select * from emp where rownum= 1 Sele...
-
Hi All, Today we are going to discuss about the log hours in a school , Create table std_logs ( SID NUMBER, IN_TIME DATE, OUT_...








