﻿set xact_abort on
go

begin transaction
go

update LogStatoIstObj set CodStato = N'' where CodStato is null
go

alter table LogStatoIstObj alter column
 CodStato nvarchar(50) not null
go

exec sp_rename 'PK_LogStatoIstObj', 'PK_LogStatoIstObj_1', 'object'
go

alter table LogStatoIstObj drop
 constraint FK_LogStatoIstObj_IstObj 
go

alter table LogStatoIstObj add
 constraint FK_LogStatoIstObj_IstObj foreign key(IdxObj) references IstObj(IdxObj) on update cascade on delete cascade
go

commit
go


set xact_abort on
go

begin transaction
go

set ANSI_NULLS on
go

/***********************************
* STORED PROCEDURE sp_delRow
*         elimina un set di dati a partire dalla riga di una commessa
*
* modif.:        S.E.L.
* il:                2008.10.23
**************************************/
alter PROCEDURE sp_delRow
(
       @Original_Cod VARCHAR(50)
)
AS

BEGIN TRAN

       -- cancello ULP child
       DELETE FROM IstObj
       WHERE     (IdxObjMamma = @Original_Cod) 

       -- cancello riga...
       DELETE FROM IstObj
       WHERE     (IdxObj = @Original_Cod) 

COMMIT TRAN

RETURN
go

commit
go


-- registro versione...
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(131, GETDATE())
GO
