IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[VWICMAL]') AND OBJECTPROPERTY(id,N'IsVIew') = 1)
BEGIN
    INSERT INTO SCRIPT_BACKUPS (SCRIPTNAME,SCRIPT,SCRIPTDATE) SELECT 'VWICMAL' SCRIPTNAME,OBJECT_DEFINITION(OBJECT_ID('VWICMAL')) AS SCRIPT,GETDATE() AS SCRIPTDATE
    DROP VIEW VWICMAL
END
GO

CREATE VIEW [dbo].[VWICMAL]
AS
SELECT ICMALID, 
       TARIH, 
       CARIID, 
       YERI, 
       BASTARIH, 
       SONTARIH, 
       SIGORTALITURU, 
       ACIKLAMA, 
       KURUMTURU, 
       CARIGRUPID, 
       CARIANAGRUPID, 
       BOLUMID, 
       GSSFATDEVKURUMID, 
       GSSFATNO, 
       dbo.ICMAL_FATURA_LISTE(ICMALID) AS FATURALAR, 
       ICMALDURUM, 
       GSSTESLIMNO, 
       SIRANO, 
       MDLPROVTURUKOD, 
       SUBEID, 
       SIRALAMATIPID, 
       MDLKAYITSAYI, 
       TOPLAMTUTAR, 
       FATTUTAR, 
       DOSYASAYISI, 
       ODEMEDURUM, 
       ENO, 
       DONEMBASI, 
       DONEMSONU, 
       EVRAKREFNO, 
       PAKETNO, 
       PKTGONTRH
FROM dbo.ICMAL WITH(NOLOCK);
GO


