﻿GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;



GO
PRINT N'Dropping [dbo].[T_CIM].[C_KOZTERULETJELLEGE].[MS_Description]...';


GO
EXECUTE sp_dropextendedproperty @name = N'MS_Description', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_CIM', @level2type = N'COLUMN', @level2name = N'C_KOZTERULETJELLEGE';


GO
PRINT N'Dropping [dbo].[T_FELHASZNALO].[C_ADOSZAM].[MS_Description]...';


GO
EXECUTE sp_dropextendedproperty @name = N'MS_Description', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_FELHASZNALO', @level2type = N'COLUMN', @level2name = N'C_ADOSZAM';


GO
PRINT N'Dropping [dbo].[T_INTEZMENYADATOK].[C_KOZTERULETJELLEG].[MS_Description]...';


GO
EXECUTE sp_dropextendedproperty @name = N'MS_Description', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_INTEZMENYADATOK', @level2type = N'COLUMN', @level2name = N'C_KOZTERULETJELLEG';


GO
PRINT N'Dropping [dbo].[T_MUKODESIHELY].[C_KOZTERULETJELLEG].[MS_Description]...';


GO
EXECUTE sp_dropextendedproperty @name = N'MS_Description', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUKODESIHELY', @level2type = N'COLUMN', @level2name = N'C_KOZTERULETJELLEG';


GO
PRINT N'Dropping [dbo].[FK_Cim_KozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg]...';


GO
ALTER TABLE [dbo].[T_CIM] DROP CONSTRAINT [FK_Cim_KozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg];


GO
PRINT N'Dropping [dbo].[FK_IntezmenyAdatok_KozteruletJelleg_IntezmenyId_TanevId_REF_KozteruletJelleg]...';


GO
ALTER TABLE [dbo].[T_INTEZMENYADATOK] DROP CONSTRAINT [FK_IntezmenyAdatok_KozteruletJelleg_IntezmenyId_TanevId_REF_KozteruletJelleg];


GO
PRINT N'Dropping [dbo].[FK_MukodesiHely_KozteruletJelleg_IntezmenyId_TanevId_REF_KozteruletJelleg]...';


GO
ALTER TABLE [dbo].[T_MUKODESIHELY] DROP CONSTRAINT [FK_MukodesiHely_KozteruletJelleg_IntezmenyId_TanevId_REF_KozteruletJelleg];


GO
PRINT N'Dropping [dbo].[FK_Nebulo_KozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg]...';


GO
ALTER TABLE [dbo].[T_NEBULO] DROP CONSTRAINT [FK_Nebulo_KozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg];


GO
PRINT N'Dropping [dbo].[FK_Nebulo_THKozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg]...';


GO
ALTER TABLE [dbo].[T_NEBULO] DROP CONSTRAINT [FK_Nebulo_THKozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg];


GO
PRINT N'Dropping [dbo].[FK_Nebulo_TKKozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg]...';


GO
ALTER TABLE [dbo].[T_NEBULO] DROP CONSTRAINT [FK_Nebulo_TKKozteruletJellege_IntezmenyId_TanevId_REF_KozteruletJelleg];


GO
PRINT N'Dropping [dbo].[FK_Nebulo_TKKozteruletJellege2_IntezmenyId_TanevId_REF_KozteruletJelleg]...';


GO
ALTER TABLE [dbo].[T_NEBULO] DROP CONSTRAINT [FK_Nebulo_TKKozteruletJellege2_IntezmenyId_TanevId_REF_KozteruletJelleg];



GO
DROP INDEX IF EXISTS [NCI_Cim_IntezmenyId_TanevId_KozteruletJellege] ON [dbo].[T_CIM]

GO
CREATE NONCLUSTERED INDEX [NCI_Cim_IntezmenyId_TanevId_KozteruletJellege] ON [dbo].[T_CIM]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_KOZTERULETJELLEGENEV] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


GO
DROP INDEX IF EXISTS [NCI_Cim_FelhasznaloId_Gondviseloid_CimTipusa_IntezmenyId] ON [dbo].[T_CIM]

GO
CREATE NONCLUSTERED INDEX [NCI_Cim_FelhasznaloId_Gondviseloid_CimTipusa_IntezmenyId] ON [dbo].[T_CIM]
(
	[C_FELHASZNALOID] ASC,
	[C_GONDVISELOID] ASC,
	[C_CIMTIPUSA] ASC,
	[C_INTEZMENYID] ASC
)
INCLUDE([C_AJTO],[C_EMELET],[C_HAZSZAM],[C_IRANYITOSZAM],[C_KOZTERULET],[C_KOZTERULETJELLEGENEV],[C_VAROS],[C_ALAPERTELMEZETT],[C_TANEVID]) 
WHERE ([TOROLT]='F')
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]


GO
PRINT N'Altering [dbo].[T_CIM]...';


GO
ALTER TABLE [dbo].[T_CIM] DROP COLUMN [C_KOZTERULETJELLEGE];


GO
PRINT N'Altering [dbo].[T_ERTEKELESMOD]...';


GO
ALTER TABLE [dbo].[T_ERTEKELESMOD]
    ADD [C_ISBOLD] CHAR (1) DEFAULT ('F') NOT NULL;


GO
PRINT N'Altering [dbo].[T_FELHASZNALO]...';


GO
ALTER TABLE [dbo].[T_FELHASZNALO]
    ADD [C_ADOAZONOSITOJEL] NVARCHAR (10) NULL;

GO
UPDATE T_FELHASZNALO
SET C_ADOAZONOSITOJEL = C_ADOSZAM


GO
ALTER TABLE [dbo].[T_FELHASZNALO] DROP COLUMN [C_ADOSZAM];


GO
DROP INDEX IF EXISTS [NCI_IntezmenyAdatok_IntezmenyId_TanevId_KozteruletJelleg] ON [dbo].[T_INTEZMENYADATOK]


GO
CREATE NONCLUSTERED INDEX [NCI_IntezmenyAdatok_IntezmenyId_TanevId_KozteruletJelleg] ON [dbo].[T_INTEZMENYADATOK]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_KOZTERULETJELLEGENEV] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]



GO
PRINT N'Altering [dbo].[T_INTEZMENYADATOK]...';


GO
ALTER TABLE [dbo].[T_INTEZMENYADATOK] DROP COLUMN [C_KOZTERULETJELLEG];


GO
PRINT N'Altering [dbo].[T_MUKODESIHELY]...';


GO
DROP INDEX IF EXISTS [NCI_MukodesiHely_IntezmenyId_TanevId_KozteruletJelleg] ON [dbo].[T_MUKODESIHELY]


GO
CREATE NONCLUSTERED INDEX [NCI_MukodesiHely_IntezmenyId_TanevId_KozteruletJelleg] ON [dbo].[T_MUKODESIHELY]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_KOZTERULETJELLEGENEV] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
ALTER TABLE [dbo].[T_MUKODESIHELY] DROP COLUMN [C_KOZTERULETJELLEG];


GO
PRINT N'Altering [dbo].[T_NEBULO]...';


GO
DROP INDEX IF EXISTS [NCI_Nebulo_IntezmenyId_TanevId_KozteruletJellege] ON [dbo].[T_NEBULO]

GO
CREATE NONCLUSTERED INDEX [NCI_Nebulo_IntezmenyId_TanevId_KozteruletJellege] ON [dbo].[T_NEBULO]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_KOZTERULETJELLEGENEV] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


GO
DROP INDEX IF EXISTS [NCI_Nebulo_IntezmenyId_TanevId_THKozteruletJellege] ON [dbo].[T_NEBULO]

GO
CREATE NONCLUSTERED INDEX [NCI_Nebulo_IntezmenyId_TanevId_THKozteruletJellege] ON [dbo].[T_NEBULO]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_KOZTERULETJELLEGENEV] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


GO
DROP INDEX IF EXISTS [NCI_Nebulo_IntezmenyId_TanevId_TKKozteruletJellege2] ON [dbo].[T_NEBULO]

GO
CREATE NONCLUSTERED INDEX [NCI_Nebulo_IntezmenyId_TanevId_TKKozteruletJellege2] ON [dbo].[T_NEBULO]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_KOZTERULETJELLEGENEV] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


GO
DROP INDEX IF EXISTS [NCI_Nebulo_IntezmenyId_TanevId_TKKozteruletJellege] ON [dbo].[T_NEBULO]

GO
CREATE NONCLUSTERED INDEX [NCI_Nebulo_IntezmenyId_TanevId_TKKozteruletJellege] ON [dbo].[T_NEBULO]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_KOZTERULETJELLEGENEV] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]



GO
ALTER TABLE [dbo].[T_NEBULO] DROP COLUMN [C_KOZTERULETJELLEGE], COLUMN [C_THKOZTERULETJELLEGE], COLUMN [C_TKKOZTERULETJELLEGE], COLUMN [C_TKKOZTERULETJELLEGE2];



GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Adóazonosító jel ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_FELHASZNALO', @level2type = N'COLUMN', @level2name = N'C_ADOAZONOSITOJEL';



GO
PRINT N'Update complete.';


GO
EXEC dev.uspCreateSchemaViews 'T_CIM, T_FELHASZNALO, T_INTEZMENYADATOK, T_MUKODESIHELY, T_NEBULO, T_ERTEKELESMOD';
GO


EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll
GO

ALTER QUEUE auditLog.[AuditQueue]
WITH ACTIVATION (
  STATUS = ON,
  PROCEDURE_NAME = auditLog.usp_AuditProcessing,
  MAX_QUEUE_READERS = 10,
  EXECUTE AS 'Kreta_tech_user'
);

GO
