https://community.dynamics.com/gp/f/32/p/162238/392546#392546
- Run This
--------------------------------
DROP INDEX [AK2ASIEXP86] ON [DYNAMICS].[dbo].[ASIEXP86]
Create trigger ctrig_SY07240_ii on [DYNAMICS].[dbo].[SY07240] instead of insert as
begin
insert [DYNAMICS].[dbo].[SY07240] (ListDictID, ListID, ViewID, CmdParentDictID, CmdParentFormID, CmdParentCmdID, CmdSequence, CmdDictID, CmdFormID, CmdID, Priority, ButtonSize, CmdCaption, Visible)
select ListDictID, ListID, ViewID, CmdParentDictID, CmdParentFormID, CmdParentCmdID, isnull(CmdSequence, 1), CmdDictID, CmdFormID, CmdID, Priority, ButtonSize, CmdCaption, Visible
from inserted
end
------------------------------------
- Run GP Utilities
- Complete the upgrade
- Run This
--------------------------------------------
begin tran
WITH CTE AS(
SELECT [ASI_Favorite_Dict_ID],
[ASI_Favorite_Type],
[ASI_Favorite_Save_Level],
[CMPANYID],
[USRCLASS],
[USERID],
[ASI_Favorite_Name],
[ASI_Field_Number_Dict_ID],
[ASI_Field_Number],
[ASI_Field_Sequence],
RN = ROW_NUMBER()OVER(PARTITION BY
[ASI_Favorite_Dict_ID],
[ASI_Favorite_Type],
[ASI_Favorite_Save_Level],
[CMPANYID],
[USRCLASS],
[USERID],
[ASI_Favorite_Name],
[ASI_Field_Number_Dict_ID],
[ASI_Field_Number]
ORDER BY [ASI_Favorite_Dict_ID],
[ASI_Favorite_Type],
[ASI_Favorite_Save_Level],
[CMPANYID],
[USRCLASS],
[USERID],
[ASI_Favorite_Name],
[ASI_Field_Number_Dict_ID],
[ASI_Field_Number], [ASI_Field_Sequence])
FROM dbo.ASIEXP86
)
DELETE FROM CTE WHERE RN > 1
commit
WITH CTE AS(
SELECT [ASI_Favorite_Dict_ID],
[ASI_Favorite_Type],
[ASI_Favorite_Save_Level],
[CMPANYID],
[USRCLASS],
[USERID],
[ASI_Favorite_Name],
[ASI_Field_Number_Dict_ID],
[ASI_Field_Number],
[ASI_Field_Sequence],
RN = ROW_NUMBER()OVER(PARTITION BY
[ASI_Favorite_Dict_ID],
[ASI_Favorite_Type],
[ASI_Favorite_Save_Level],
[CMPANYID],
[USRCLASS],
[USERID],
[ASI_Favorite_Name],
[ASI_Field_Number_Dict_ID],
[ASI_Field_Number]
ORDER BY [ASI_Favorite_Dict_ID],
[ASI_Favorite_Type],
[ASI_Favorite_Save_Level],
[CMPANYID],
[USRCLASS],
[USERID],
[ASI_Favorite_Name],
[ASI_Field_Number_Dict_ID],
[ASI_Field_Number], [ASI_Field_Sequence])
FROM dbo.ASIEXP86
)
DELETE FROM CTE WHERE RN > 1
commit
---------------------------------------------------------------------------------------
USE [DYNAMICS]
GO
GO
/****** Object: Index [AK2ASIEXP86] ******/
CREATE UNIQUE NONCLUSTERED INDEX [AK2ASIEXP86] ON [dbo].[ASIEXP86]
(
[ASI_Favorite_Dict_ID] ASC,
[ASI_Favorite_Type] ASC,
[ASI_Favorite_Save_Level] ASC,
[CMPANYID] ASC,
[USRCLASS] ASC,
[USERID] ASC,
[ASI_Favorite_Name] ASC,
[ASI_Field_Number_Dict_ID] ASC,
[ASI_Field_Number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [AK2ASIEXP86] ON [dbo].[ASIEXP86]
(
[ASI_Favorite_Dict_ID] ASC,
[ASI_Favorite_Type] ASC,
[ASI_Favorite_Save_Level] ASC,
[CMPANYID] ASC,
[USRCLASS] ASC,
[USERID] ASC,
[ASI_Favorite_Name] ASC,
[ASI_Field_Number_Dict_ID] ASC,
[ASI_Field_Number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
GO
-------------------------------------------------------------------------------------
DROP TRIGGER [ctrig_SY07240_ii] ON [DYNAMICS].[dbo].[SY07240]
No comments:
Post a Comment