You are on page 1of 1

select * from employee

alter table employee


add
id_employee int identity(1,1),
age int,
constraint PK_employee primary key (id_employee)

SELECT YEAR ( '2013-02-12' ) as year,


MONTH( '2013-02-12' ) as month,
DAY ( '2013-02-12' ) as day

SELECT YEAR ( '2013-02-12' ) as year,


MONTH( '2013-02-12' ) as month,
DAY ( '2013-02-12' ) as day
SELECT SYSDATETIME(),
SYSDATETIMEOFFSET(),
GETDATE(),
GETUTCDATE() SYSDATETIME(),
SYSDATETIMEOFFSET(),
GETDATE(),
GETUTCDATE()
getdate()

select DATEDIFF(year,BirthDate , getdate()) as age from employee

update employee set age=DATEDIFF(year,BirthDate , getdate())

select * from employee order by age

select * from employee order by birthdate desc

SELECT FirstName, LastName, BirthDate,


DATEDIFF ( yy , BirthDate , GETDATE() ) as Age
FROM dbo.Employee

select count(*) as no, age from employee group by age

select top 3 * into new_table from employee

select * from new_table

You might also like