hello!
how to create DML trigger Sync_employee_backup_trigger which synchronise the employee data with their backup table on insert,update and delete employee event
create table scalar function calculate_salary which will return total salary of employees of a department.
Table entries are:
Employee_Id bigint identity (1000,1) PK
First Name nvarchar(64)
Last Name nvarchar(64)
Department_Name nvarchar(128)
Salary decimal (18,5)
// in SQL Server
Loading

Ramesh MaruthiPosted Jun 27, 2014, 10:36 AM
GO
/****** Object: UserDefinedFunction [dbo].[UDF_CalculateSalary ]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[UDF_CalculateSalary]
RETURNS @Employees TABLE(Department_Name nvarchar(128), Salary decimal(18,5))
AS
BEGIN
Insert Into @Employees(Department_Name,Salary )
SELECT Department_Name, SUM(Salary)FROM employees GROUP BY Department_Name
RETURN
END
GO