Selasa, 01 Mei 2012

Bls: [belajar-access] Trigger Insert Data Ke Tabel Setiap Akhir Bulan

 

maaf bang sofyan saya tanya lagi.
saya sudah coba yang dari bang sofyan
mohon dikoreksi


create trigger isidata
for insert
as

    If getdate()=DateSerial(Year(getdate()), Month(getdate()) + 1, 0) then
        insert into tabelA (a1,a2)values ('1','2')
   
    end if
go
setelah saya jalankan di query analiser muncul error :

Server: Msg 156, Level 15, State 1, Procedure isidata, Line 2
Incorrect syntax near the keyword 'for'.
Server: Msg 195, Level 15, State 1, Procedure isidata, Line 5
'DateSerial' is not a recognized function name.
Server: Msg 156, Level 15, State 1, Procedure isidata, Line 8
Incorrect syntax near the keyword 'end'.

saya menggunakan sql server 2000

mohon pencerahannya

Dari: Sofyan Efendi <sofyanefendi@gmail.com>
Kepada: belajar-access@yahoogroups.com
Dikirim: Jumat, 27 April 2012 16:20
Judul: Re: [belajar-access] Trigger Insert Data Ke Tabel Setiap Akhir Bulan

 

Masya Allah, terlewat karena kasus ADP :))
Untuk mencari tgl akhir setiap bulan, rumusnya: DateSerial(Year(DateField), Month(DateField) + 1, 0)
Untuk insert data dari table A ke table B, bisa menggunakan query append.
Untuk mengetahui apakah hari ini sudah akhir bulan atau tidak, bisa menggunakan fungsi IF.
Sehingga, untuk trigger:
 
If date()=DateSerial(Year(Date()), Month(Date()) + 1, 0) then
    'lakukan proses append query disini
    ...
end if
Nah, sekarang tinggal disesuaikan dengan table dan kondisi di file Accessnya Mas Galih.
 
Wassalaamu'alaikum Warahmatullahi Wabarakatuh,
Sofyan Efendi
http://imopi.wordpress.com/
----- Original Message -----
Sent: Thursday, April 26, 2012 10:44 PM
Subject: [belajar-access] Trigger Insert Data Ke Tabel Setiap Akhir Bulan

Mohon informasi untuk trigger yang berfungsi untuk meng insert data dari tabel A ke tabel B setian akhir bulan.
Terima kasih atas pencerahannya


__._,_.___
Recent Activity:
SPAM IS PROHIBITED
.

__,_._,___

Tidak ada komentar:

Posting Komentar