Files
GMW/GMW_data/SqlScripts/V1.2/GMW_00437-TK-01.sql
T
Samuele E. Locatelli bdd7b413e8 Riaggiunto GMW_data
2016-11-22 17:58:00 +01:00

81 lines
1.6 KiB
Transact-SQL

-- stati prodotto...
alter table AnagStatiProdotto add
CodGruppo nvarchar(50)
go
-- relazioni UDC
set xact_abort on
go
begin transaction
go
alter table RelazUDC add
dataMod datetime constraint DF_RelazUDC_dataMod default (getdate())
go
commit
go
update RelazUDC
set dataMod ='2012-01-01'
where ISNULL(dataMod,'2012-01-01') = '2012-01-01'
GO
-- blocchi
set xact_abort on
go
begin transaction
go
alter table Blocchi drop
constraint i_CodBlocco ,
constraint FK_Blocchi_AnagMag
go
exec sp_rename 'PK_Blocchi', 'tmp__PK_Blocchi', 'OBJECT'
go
exec sp_rename 'Blocchi', 'tmp__Blocchi_1', 'OBJECT'
go
create table Blocchi(
IdxBlocco int not null constraint PK_Blocchi primary key,
CodMag nvarchar(50),
CodCS nchar(2),
CodBlocco nvarchar(3) not null constraint i_CodBlocco unique,
DescBlocco nvarchar(50),
NumX int,
NumY int,
NumZ int
)
go
alter table Blocchi add
constraint FK_Blocchi_AnagMag foreign key(CodMag,CodCS) references AnagMag(CodMag,CodCS) on update cascade
go
exec sp_addextendedproperty 'MS_Description', 'numero elementi X (colonne)', 'SCHEMA', 'dbo', 'TABLE', 'Blocchi', 'COLUMN', 'NumX'
go
exec sp_addextendedproperty 'MS_Description', 'numero elementi Y (livelli/ripiani)', 'SCHEMA', 'dbo', 'TABLE', 'Blocchi', 'COLUMN', 'NumY'
go
exec sp_addextendedproperty 'MS_Description', 'numero elementi Z (profondita)', 'SCHEMA', 'dbo', 'TABLE', 'Blocchi', 'COLUMN', 'NumZ'
go
insert into Blocchi(IdxBlocco,CodMag,CodCS,CodBlocco,DescBlocco,NumX,NumY,NumZ) select IdxBlocco,CodMag,CodCS,CodBlocco,DescBlocco,NumX,NumY,NumZ from tmp__Blocchi_1
go
drop table tmp__Blocchi_1
go
commit
go