Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Is it correct way to write the following trigger?

$
0
0
USE [dbo]
GO
/****** Object:  Trigger [dbo].[month_u2]    Script Date: 02/01/2014 13:18:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[month_u2]
   ON  [dbo].[tfc_work_vouchers] 
   AFTER INSERT
AS 


BEGIN

update tfc_work_vouchers set month='1' where month(voucher_date)=4

update tfc_work_vouchers set month='2' where month(voucher_date)=5

update tfc_work_vouchers set month='3' where month(voucher_date)=6

update tfc_work_vouchers set month='4' where month(voucher_date)=7

update tfc_work_vouchers set month='5' where month(voucher_date)=8

update tfc_work_vouchers set month='6' where month(voucher_date)=9    

update tfc_work_vouchers set month='7' where month(voucher_date)=10

update tfc_work_vouchers set month='8' where month(voucher_date)=11

update tfc_work_vouchers set month='9' where month(voucher_date)=12   

update tfc_work_vouchers set month='10' where month(voucher_date)=1

update tfc_work_vouchers set month='11' where month(voucher_date)=2

update tfc_work_vouchers set month='12' where month(voucher_date)=3

END

Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>