Commit for development environment setup
This commit is contained in:
137
PROMS/SQL/1_Approval_Tables.sql
Normal file
137
PROMS/SQL/1_Approval_Tables.sql
Normal file
@@ -0,0 +1,137 @@
|
||||
/****** Object: Table [dbo].[Stages] Script Date: 10/21/2011 15:04:48 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Stages](
|
||||
[StageID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](50) NOT NULL,
|
||||
[Description] [nvarchar](200) NULL,
|
||||
[IsApproved] [int] NOT NULL CONSTRAINT [DF_Stages_IsApproved] DEFAULT ((0)),
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Stages_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Stages_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Stages] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[StageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Stages', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
|
||||
/****** Object: Table [dbo].[Revisions] Script Date: 10/21/2011 15:06:44 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Revisions](
|
||||
[RevisionID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ItemID] [int] NOT NULL,
|
||||
[TypeID] [int] NOT NULL CONSTRAINT [DF_Revisions_TypeID] DEFAULT ((1)),
|
||||
[RevisionNumber] [nvarchar](50) NULL,
|
||||
[RevisionDate] [datetime] NULL,
|
||||
[Notes] [nvarchar](max) NULL,
|
||||
[Config] [xml] NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Revisions_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Revisions_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Revisions] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RevisionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Revisions', @level2type=N'COLUMN',@level2name=N'RevisionDate'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Revisions', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[Checks] Script Date: 10/21/2011 15:07:45 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Checks](
|
||||
[CheckID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[StageID] [int] NOT NULL,
|
||||
[ConsistencyChecks] [xml] NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Checks_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Checks_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Checks] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[CheckID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Checks', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Checks] WITH CHECK ADD CONSTRAINT [FK_Checks_Revisions] FOREIGN KEY([RevisionID])
|
||||
REFERENCES [dbo].[Revisions] ([RevisionID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Checks] CHECK CONSTRAINT [FK_Checks_Revisions]
|
||||
GO
|
||||
ALTER TABLE [dbo].[Checks] WITH CHECK ADD CONSTRAINT [FK_Checks_Stages] FOREIGN KEY([StageID])
|
||||
REFERENCES [dbo].[Stages] ([StageID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Checks] CHECK CONSTRAINT [FK_Checks_Stages]
|
||||
|
||||
/****** Object: Table [dbo].[Versions] Script Date: 10/21/2011 15:09:15 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Versions](
|
||||
[VersionID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[StageID] [int] NOT NULL,
|
||||
[PDF] [varbinary](max) NULL,
|
||||
[SummaryPDF] [varbinary](max) NULL,
|
||||
[DTS] [datetime] NOT NULL,
|
||||
[UserID] [nvarchar](200) NOT NULL,
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Version] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[VersionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
SET ANSI_PADDING OFF
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Versions', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Versions] WITH CHECK ADD CONSTRAINT [FK_Versions_Revisions] FOREIGN KEY([RevisionID])
|
||||
REFERENCES [dbo].[Revisions] ([RevisionID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Versions] CHECK CONSTRAINT [FK_Versions_Revisions]
|
||||
GO
|
||||
ALTER TABLE [dbo].[Versions] WITH CHECK ADD CONSTRAINT [FK_Versions_Stages] FOREIGN KEY([StageID])
|
||||
REFERENCES [dbo].[Stages] ([StageID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Versions] CHECK CONSTRAINT [FK_Versions_Stages]
|
||||
|
||||
|
||||
--put in stage data
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Input to review','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Initial review','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Final review','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Verification','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Validation','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Issued','',1,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Published','',1,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Approved','',1,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
--end put in stage data
|
126
PROMS/SQL/1_Approval_Tables.sql.bak
Normal file
126
PROMS/SQL/1_Approval_Tables.sql.bak
Normal file
@@ -0,0 +1,126 @@
|
||||
/****** Object: Table [dbo].[Stages] Script Date: 10/21/2011 15:04:48 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Stages](
|
||||
[StageID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](50) NOT NULL,
|
||||
[Description] [nvarchar](200) NULL,
|
||||
[IsApproved] [int] NOT NULL CONSTRAINT [DF_Stages_IsApproved] DEFAULT ((0)),
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Stages_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Stages_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Stages] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[StageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Stages', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
|
||||
/****** Object: Table [dbo].[Revisions] Script Date: 10/21/2011 15:06:44 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Revisions](
|
||||
[RevisionID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ItemID] [int] NOT NULL,
|
||||
[TypeID] [int] NOT NULL CONSTRAINT [DF_Revisions_TypeID] DEFAULT ((1)),
|
||||
[RevisionNumber] [nvarchar](50) NULL,
|
||||
[RevisionDate] [datetime] NULL,
|
||||
[Notes] [nvarchar](max) NULL,
|
||||
[Config] [xml] NULL,
|
||||
CONSTRAINT [PK_Revisions] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RevisionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Revisions', @level2type=N'COLUMN',@level2name=N'RevisionDate'
|
||||
|
||||
/****** Object: Table [dbo].[Checks] Script Date: 10/21/2011 15:07:45 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Checks](
|
||||
[CheckID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[StageID] [int] NOT NULL,
|
||||
[ConsistencyChecks] [xml] NULL,
|
||||
CONSTRAINT [PK_Checks] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[CheckID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
ALTER TABLE [dbo].[Checks] WITH CHECK ADD CONSTRAINT [FK_Checks_Revisions] FOREIGN KEY([RevisionID])
|
||||
REFERENCES [dbo].[Revisions] ([RevisionID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Checks] CHECK CONSTRAINT [FK_Checks_Revisions]
|
||||
GO
|
||||
ALTER TABLE [dbo].[Checks] WITH CHECK ADD CONSTRAINT [FK_Checks_Stages] FOREIGN KEY([StageID])
|
||||
REFERENCES [dbo].[Stages] ([StageID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Checks] CHECK CONSTRAINT [FK_Checks_Stages]
|
||||
|
||||
/****** Object: Table [dbo].[Versions] Script Date: 10/21/2011 15:09:15 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Versions](
|
||||
[VersionID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[StageID] [int] NOT NULL,
|
||||
[DTS] [datetime] NOT NULL,
|
||||
[UserID] [nvarchar](200) NOT NULL,
|
||||
[PDF] [varbinary](max) NULL,
|
||||
[SummaryPDF] [varbinary](max) NULL,
|
||||
CONSTRAINT [PK_Version] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[VersionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
SET ANSI_PADDING OFF
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Versions', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
ALTER TABLE [dbo].[Versions] WITH CHECK ADD CONSTRAINT [FK_Versions_Revisions] FOREIGN KEY([RevisionID])
|
||||
REFERENCES [dbo].[Revisions] ([RevisionID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Versions] CHECK CONSTRAINT [FK_Versions_Revisions]
|
||||
GO
|
||||
ALTER TABLE [dbo].[Versions] WITH CHECK ADD CONSTRAINT [FK_Versions_Stages] FOREIGN KEY([StageID])
|
||||
REFERENCES [dbo].[Stages] ([StageID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Versions] CHECK CONSTRAINT [FK_Versions_Stages]
|
||||
|
||||
|
||||
--put in stage data
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Input to review','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Initial review','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Final review','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Verification','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Validation','',0,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Issued','',1,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Published','',1,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
INSERT INTO [dbo].[Stages] ([Name],[Description],[IsApproved],[DTS],[UserID]) VALUES ('Approved','',1,getdate(),'VOLIAN\BODINE')
|
||||
GO
|
||||
--end put in stage data
|
1273
PROMS/SQL/2_Approval_CSLAProcs.sql
Normal file
1273
PROMS/SQL/2_Approval_CSLAProcs.sql
Normal file
File diff suppressed because it is too large
Load Diff
1189
PROMS/SQL/2_Approval_CSLAProcs.sql.bak
Normal file
1189
PROMS/SQL/2_Approval_CSLAProcs.sql.bak
Normal file
File diff suppressed because it is too large
Load Diff
716
PROMS/SQL/3_Approval_SupportProcsFuncs.sql
Normal file
716
PROMS/SQL/3_Approval_SupportProcsFuncs.sql
Normal file
@@ -0,0 +1,716 @@
|
||||
/****** Object: StoredProcedure [dbo].[getTransitionsFromProc] Script Date: 10/21/2011 15:19:55 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
/*
|
||||
getTransitionsFromProc 10
|
||||
*/
|
||||
create PROCEDURE [dbo].[getTransitionsFromProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT tt.[TransitionID]
|
||||
,[FromID]
|
||||
,[ToID]
|
||||
,[RangeID]
|
||||
,[IsRange]
|
||||
,[TranType]
|
||||
,tt.[Config]
|
||||
,tt.[DTS]
|
||||
,tt.[UserID]
|
||||
,tt.[LastChanged]
|
||||
,(SELECT COUNT(*) FROM [ZTransitions] WHERE [ZTransitions].[TransitionID]=[tt].[TransitionID]) [ZTransitionCount]
|
||||
,cc.text ContentText
|
||||
FROM [Transitions] tt
|
||||
inner join contents cc on tt.fromid = cc.contentid
|
||||
WHERE transitionid in (select transitionid from vefn_FindExternalFromTransitions(@ItemID))
|
||||
RETURN
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getTransitionsToProc] Script Date: 10/21/2011 15:24:11 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
/*
|
||||
getTransitionsToProc 10
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[getTransitionsToProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT tt.[TransitionID]
|
||||
,[FromID]
|
||||
,[ToID]
|
||||
,[RangeID]
|
||||
,[IsRange]
|
||||
,[TranType]
|
||||
,tt.[Config]
|
||||
,tt.[DTS]
|
||||
,tt.[UserID]
|
||||
,tt.[LastChanged]
|
||||
,(SELECT COUNT(*) FROM [ZTransitions] WHERE [ZTransitions].[TransitionID]=[tt].[TransitionID]) [ZTransitionCount]
|
||||
,cc.text ContentText
|
||||
FROM [Transitions] tt
|
||||
inner join contents cc on tt.fromid = cc.contentid
|
||||
WHERE transitionid in (select transitionid from vefn_FindExternalTransitions(@ItemID))
|
||||
RETURN
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_FindExternalFromTransitions] Script Date: 10/21/2011 15:27:17 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
Select * from vefn_FindExternalFromTransitions(185)
|
||||
*/
|
||||
|
||||
create FUNCTION [dbo].[vefn_FindExternalFromTransitions](@ItemID int)
|
||||
RETURNS @Children TABLE
|
||||
(
|
||||
[FromItemID] int,
|
||||
[TransitionID] [int] NOT NULL,
|
||||
[FromID] [int] NOT NULL,
|
||||
[ToID] [int] NOT NULL,
|
||||
[RangeID] [int] NOT NULL,
|
||||
[Config] [nvarchar](max) NULL
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
with Itemz([Level], [Ordinal], [ItemID], [PreviousID], [FromType], [ContentID], [DTS], [UserID], [LastChanged],[pContentID], [pDTS],[pUserID],[pLastChanged]) as (
|
||||
Select 0 [Level], 0 [Ordinal], [ItemID], [PreviousID],0 [FromType],[ContentID],[DTS],[UserID],[LastChanged]
|
||||
,0 [pContentID],[DTS] [pDTS], [UserID] [pUserID], [LastChanged] [pLastChanged]
|
||||
FROM [Items]
|
||||
where [ItemID]=@ItemID
|
||||
Union All
|
||||
-- Children
|
||||
select [Level] + 1,0, I.[ItemID], I.[PreviousID], P.[FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,P.[ContentID] [pContentID],P.[DTS] [pDTS],P.[UserID] [pUserID],P.[LastChanged] [pLastChanged]
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
-- Siblings
|
||||
Union All
|
||||
select [Level] ,Z.[Ordinal] +1, I.[ItemID], I.[PreviousID], [FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,null,null,null,null
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
where Z.[Level] > 0
|
||||
)
|
||||
insert into @Children
|
||||
select ItemID [FromItemID], TT.[TransitionID], TT.[FromID], TT.[ToID], TT.[RangeID], TT.[Config]
|
||||
from Transitions TT
|
||||
join Items II on II.ContentID=TT.FromID
|
||||
where (ToID not in(select ItemID from Itemz) OR RangeID not in(select ItemID from Itemz))
|
||||
AND FromID in(Select ContentID from ItemZ)
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getLibDocsForProc] Script Date: 10/21/2011 15:28:43 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
/*
|
||||
getLibDocsForProc 10
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[getLibDocsForProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT dd.[DocID]
|
||||
,[LibTitle]
|
||||
,[DocContent]
|
||||
,[DocAscii]
|
||||
,[Config]
|
||||
,dd.[DTS]
|
||||
,dd.[UserID]
|
||||
,dd.[LastChanged]
|
||||
,[FileExtension],
|
||||
(SELECT COUNT(*) FROM [DROUsages] WHERE [DROUsages].[DocID]=[dd].[DocID]) [DROUsageCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[DocID]=[dd].[DocID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Pdfs] WHERE [Pdfs].[DocID]=[dd].[DocID]) [PdfCount]
|
||||
|
||||
FROM [Documents] dd
|
||||
INNER JOIN [Entries] ee on dd.docid = ee.docid
|
||||
INNER JOIN vefn_ChildItems(@ItemID) cc on cc.contentid = ee.contentid
|
||||
RETURN
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getRoUsagesForProc] Script Date: 10/21/2011 15:31:51 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
create PROCEDURE [dbo].[getRoUsagesForProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[ROUsageID],
|
||||
rr.[ContentID],
|
||||
[ROID],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
[RODbID]
|
||||
FROM [RoUsages] rr
|
||||
INNER JOIN vefn_ChildItems(@ItemID) cc on cc.contentid = rr.contentid
|
||||
RETURN
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_CheckXML] Script Date: 10/25/2011 18:36:53 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
declare @NewXML xml
|
||||
select @NewXML = consistencychecks from checks where checkid = 48
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'2011-08-24T11:20:57.027','2011-12-25T00:00:00.000') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'88%','88.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'="6%','="6.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'23%','23.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'90%','90.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),', Step 13',', Step 14') as xml)r
|
||||
declare @OldXML xml
|
||||
select @OldXML = consistencychecks from checks where checkid = 1
|
||||
--select .dbo.vefn_CheckXML(@NewXML, @OldXML)
|
||||
select ii.*,ss.*,.dbo.vefn_CheckXML(@NewXML, consistencychecks) chkxml from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
inner join items ii on rr.itemid = ii.itemid
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
*/
|
||||
CREATE function [dbo].[vefn_CheckXML](@NewXML xml, @OldXML xml)
|
||||
returns xml
|
||||
begin
|
||||
declare @ChkXML xml
|
||||
set @ChkXML =
|
||||
(
|
||||
select
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ah.ROID,OldROValue,ROValue from
|
||||
(
|
||||
select r1.value('@ROID','varchar(20)') roid,r1.value('@ROValue','varchar(max)') oldrovalue
|
||||
from @OldXML.nodes('//ROCheck') as t1(r1)
|
||||
) ah
|
||||
inner join
|
||||
(
|
||||
select distinct r2.value('@ROID','varchar(20)') roid,r2.value('@ROValue','varchar(max)') rovalue
|
||||
from @NewXML.nodes('//ROCheck') as t2(r2)
|
||||
) ds
|
||||
on ah.roid = ds.roid
|
||||
and oldrovalue != rovalue
|
||||
) ROCheck
|
||||
for xml auto,root('ROChecks'),type
|
||||
)
|
||||
,
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ah.TransitionID,OldTransitionValue,TransitionValue from
|
||||
(
|
||||
select r1.value('@TransitionID','int') TransitionID,r1.value('@TransitionValue','varchar(max)') OldTransitionValue
|
||||
from @OldXML.nodes('//TransitionCheck') as t1(r1)
|
||||
) ah
|
||||
inner join
|
||||
(
|
||||
select distinct r2.value('@TransitionID','int') TransitionID,r2.value('@TransitionValue','varchar(max)') TransitionValue
|
||||
from @NewXML.nodes('//TransitionCheck') as t2(r2)
|
||||
) ds
|
||||
on ah.TransitionID = ds.TransitionID
|
||||
and OldTransitionValue != TransitionValue
|
||||
) TransitionCheck
|
||||
for xml auto,root('TransitionChecks'),type
|
||||
)
|
||||
,
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ah.DocID,OldDocDate,DocDate from
|
||||
(
|
||||
select r1.value('@DocID','int') docid,r1.value('@DocDate','datetime') olddocdate
|
||||
from @OldXML.nodes('//LibDocCheck') as t1(r1)
|
||||
) ah
|
||||
inner join
|
||||
(
|
||||
select distinct r2.value('@DocID','int') docid,r2.value('@DocDate','datetime') docdate
|
||||
from @NewXML.nodes('//LibDocCheck') as t2(r2)
|
||||
) ds
|
||||
on ah.docid = ds.docid
|
||||
and olddocdate != docdate
|
||||
) LibDocCheck
|
||||
for xml auto,root('LibDocChecks'),type
|
||||
)
|
||||
for xml path(''),ROOT ('ConsistencyChecks'),type
|
||||
)
|
||||
return @ChkXML
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_CheckAllXML] Script Date: 10/21/2011 15:00:56 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
select [dbo].[vefn_CheckAllXML](1)
|
||||
*/
|
||||
CREATE function [dbo].[vefn_CheckAllXML](@DocVersionID int)
|
||||
returns xml
|
||||
begin
|
||||
declare @ChkXML xml
|
||||
set @ChkXML =
|
||||
(
|
||||
select
|
||||
(--ro inconsistencies accross set
|
||||
select ItemID,ROID,ROValue from
|
||||
(
|
||||
select rr.itemid,r1.value('@ROID','varchar(max)') roid,r1.value('@ROValue','varchar(max)') rovalue
|
||||
from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
cross apply cc.consistencychecks.nodes('//ROCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
and rr.itemid in (select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
) ROCheck
|
||||
where roid in
|
||||
(
|
||||
--get roids that has more than 1 rovalue from distinct roid and rovalue from checks for latest checkid with approved stage for each itemid
|
||||
select roid from
|
||||
(
|
||||
--distinct roid and rovalue from checks for latest checkid with approved stage for each itemid
|
||||
select distinct r1.value('@ROID','varchar(max)') roid,r1.value('@ROValue','varchar(max)') rovalue
|
||||
from checks cc
|
||||
cross apply cc.consistencychecks.nodes('//ROCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
) t1
|
||||
group by roid having count(*) > 1
|
||||
)
|
||||
order by itemid
|
||||
for xml auto,root('ROChecks'),type
|
||||
),
|
||||
--jcb
|
||||
(--transition inconsistencies accross set
|
||||
select ItemID,TransitionID,TransitionValue from
|
||||
(
|
||||
select rr.itemid,r1.value('@TransitionID','int') transitionid,r1.value('@TransitionValue','varchar(max)') transitionvalue
|
||||
from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
cross apply cc.consistencychecks.nodes('//TransitionCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
and rr.itemid in (select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
) TransitionCheck
|
||||
where transitionid in
|
||||
(
|
||||
--get transitionids that has more than 1 transitionvalue from distinct transitionid and transitionvalue from checks for latest checkid with approved stage for each itemid
|
||||
select transitionid from
|
||||
(
|
||||
--distinct docid and docdate from checks for latest checkid with approved stage for each itemid
|
||||
select distinct r1.value('@TransitionID','int') transitionid,r1.value('@TransitionValue','varchar(max)') transitionvalue
|
||||
from checks cc
|
||||
cross apply cc.consistencychecks.nodes('//TransitionCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
) t1
|
||||
group by transitionid having count(*) > 1
|
||||
)
|
||||
order by itemid
|
||||
for xml auto,root('TransitionChecks'),type
|
||||
),
|
||||
--end jcb
|
||||
(--libdoc inconsistencies accross set
|
||||
select ItemID,DocID,DocDate from
|
||||
(
|
||||
select rr.itemid,r1.value('@DocID','int') docid,r1.value('@DocDate','datetime') docdate
|
||||
from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
cross apply cc.consistencychecks.nodes('//LibDocCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
and rr.itemid in (select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
) LibDocCheck
|
||||
where docid in
|
||||
(
|
||||
--get docids that has more than 1 docdate from distinct docid and docdate from checks for latest checkid with approved stage for each itemid
|
||||
select docid from
|
||||
(
|
||||
--distinct docid and docdate from checks for latest checkid with approved stage for each itemid
|
||||
select distinct r1.value('@DocID','int') docid,r1.value('@DocDate','datetime') docdate
|
||||
from checks cc
|
||||
cross apply cc.consistencychecks.nodes('//LibDocCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
) t1
|
||||
group by docid having count(*) > 1
|
||||
)
|
||||
order by itemid
|
||||
for xml auto,root('LibDocChecks'),type
|
||||
)
|
||||
for xml path(''),ROOT ('ConsistencyChecks'),type
|
||||
)
|
||||
return @ChkXML
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_CheckAllXMLByItemID] Script Date: 10/21/2011 15:01:32 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
declare @myxml xml
|
||||
set @myxml = (select dbo.vefn_checkallxml(1))
|
||||
select dbo.vefn_checkallxmlbyitemid(1,@myxml)
|
||||
*/
|
||||
CREATE function [dbo].[vefn_CheckAllXMLByItemID](@ItemID int,@MyXml xml)
|
||||
returns xml
|
||||
begin
|
||||
declare @ChkXML xml
|
||||
declare @ROCheck table
|
||||
(
|
||||
ItemID int,
|
||||
ROID varchar(max),
|
||||
ROValue varchar(max)
|
||||
)
|
||||
insert into @ROCheck
|
||||
select r2.value('@ItemID','int'),r2.value('@ROID','varchar(max)'),r2.value('@ROValue','varchar(max)')
|
||||
from @MyXml.nodes('//ROCheck') t2(r2)
|
||||
--jcb
|
||||
declare @TransitionCheck table
|
||||
(
|
||||
ItemID int,
|
||||
TransitionID int,
|
||||
TransitionValue varchar(max)
|
||||
)
|
||||
insert into @TransitionCheck
|
||||
select r2.value('@ItemID','int'),r2.value('@TransitionID','int'),r2.value('@TransitionValue','varchar(max)')
|
||||
from @MyXml.nodes('//TransitionCheck') t2(r2)
|
||||
--end jcb
|
||||
declare @LibDocCheck table
|
||||
(
|
||||
ItemID int,
|
||||
DocID int,
|
||||
DocDate datetime
|
||||
)
|
||||
insert into @LibDocCheck
|
||||
select r2.value('@ItemID','int'),r2.value('@DocID','int'),r2.value('@DocDate','datetime')
|
||||
from @MyXml.nodes('//LibDocCheck') t2(r2)
|
||||
set @ChkXML =
|
||||
(
|
||||
select
|
||||
(select * from @ROCheck ROCheck where itemid = @ItemID for xml auto, root('ROChecks'),type),
|
||||
(select * from @TransitionCheck TransitionCheck where itemid = @ItemID for xml auto, root('TransitionChecks'),type),
|
||||
(select * from @LibDocCheck LibDocCheck where itemid = @ItemID for xml auto, root('LibDocChecks'),type)
|
||||
for xml path(''),ROOT ('ConsistencyChecks'),type
|
||||
)
|
||||
return @ChkXML
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_GetConsistencyCheckProcedures] Script Date: 10/25/2011 18:38:25 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
declare @myxml xml
|
||||
select @myxml = consistencychecks from checks where checkid = 2
|
||||
declare @docversionid int
|
||||
set @docversionid = 1
|
||||
exec vesp_GetConsistencyCheckProcedures @docversionid, @myxml
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[vesp_GetConsistencyCheckProcedures]
|
||||
(
|
||||
@DocVersionID int,
|
||||
@MyXml xml
|
||||
)
|
||||
AS BEGIN
|
||||
--to be removed
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'2011-08-24T11:20:57.027','2011-12-25T00:00:00.000') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'88%','88.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'="6%','="6.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'23%','23.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'90%','90.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),', Step 13',', Step 14') as xml)
|
||||
--end to be removed
|
||||
DECLARE @Items TABLE
|
||||
(
|
||||
ID int identity(1,1),
|
||||
ItemID int
|
||||
)
|
||||
INSERT INTO @Items (itemid)
|
||||
select roc.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//ConsistencyChecks') t1(roc)
|
||||
declare @LatestApproved TABLE
|
||||
(
|
||||
ItemID int PRIMARY KEY,
|
||||
CheckID int
|
||||
)
|
||||
insert into @LatestApproved
|
||||
select rr.itemid,max(checkid) checkid
|
||||
from revisions rr
|
||||
inner join checks cc on rr.revisionid = cc.revisionid
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
where ss.isapproved = 1
|
||||
and rr.itemid in
|
||||
(select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
group by rr.itemid
|
||||
|
||||
SELECT
|
||||
ii.[ItemID]
|
||||
,ii.[PreviousID]
|
||||
,ii.[ContentID]
|
||||
,ii.[DTS]
|
||||
,ii.[UserID]
|
||||
,ii.[LastChanged]
|
||||
,CC.[Number]
|
||||
,CC.[Text]
|
||||
,CC.[Type]
|
||||
,CC.[FormatID]
|
||||
,CC.[Config]
|
||||
,CC.[DTS] [cDTS]
|
||||
,CC.[UserID] [cUserID]
|
||||
,CC.[LastChanged] [cLastChanged]
|
||||
,(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=ii.[ItemID]) [AnnotationCount]
|
||||
,(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=ii.[ItemID]) [DocVersionCount]
|
||||
,(SELECT COUNT(*) FROM [Items] [Next] WHERE [Next].[PreviousID]=ii.[ItemID]) [NextCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=ii.[ItemID]) [PartCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=ii.[ItemID]) [Transition_RangeIDCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=ii.[ItemID]) [Transition_ToIDCount]
|
||||
,(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=CC.[ContentID]) [DetailCount]
|
||||
,(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=CC.[ContentID]) [EntryCount]
|
||||
,(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=CC.[ContentID]) [GridCount]
|
||||
,(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=CC.[ContentID]) [ImageCount]
|
||||
,(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=CC.[ContentID]) [ItemCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=CC.[ContentID]) [cPartCount]
|
||||
,(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=CC.[ContentID]) [RoUsageCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=CC.[ContentID]) [TransitionCount]
|
||||
,(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=CC.[ContentID]) [ZContentCount]
|
||||
,ribeye.ChkXml
|
||||
FROM [Items] ii
|
||||
INNER JOIN [Contents] cc ON ii.[ContentID] = cc.[ContentID]
|
||||
inner join
|
||||
(
|
||||
select la.itemid,.dbo.vefn_checkxml(@myxml,cc.consistencychecks) chkxml
|
||||
from checks cc
|
||||
inner join @LatestApproved la on cc.checkid = la.checkid
|
||||
) ribeye on ii.itemid = ribeye.itemid
|
||||
left join @items iii on ii.itemid = iii.itemid
|
||||
where chkxml.exist('//ROChecks') | chkxml.exist('//TransitionChecks') | chkxml.exist('//LibDocChecks') > 0 or
|
||||
ii.ItemID in (select ItemID from @Items)
|
||||
order by isnull(iii.id,999999)
|
||||
END
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_GetAllConsistencyIssues] Script Date: 10/21/2011 15:03:40 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
[dbo].[vesp_GetAllConsistencyIssues] 1
|
||||
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[vesp_GetAllConsistencyIssues]
|
||||
(
|
||||
@DocVersionID int
|
||||
)
|
||||
AS BEGIN
|
||||
declare @myxml xml
|
||||
set @myxml = (select dbo.vefn_checkallxml(@DocVersionID))
|
||||
DECLARE @Items TABLE
|
||||
(
|
||||
ItemID int PRIMARY KEY
|
||||
)
|
||||
INSERT INTO @Items
|
||||
select r1.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//ROCheck') t1(r1)
|
||||
union
|
||||
select r1.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//TransitionCheck') t1(r1)
|
||||
union
|
||||
select r1.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//LibDocCheck') t1(r1)
|
||||
SELECT
|
||||
ii.[ItemID]
|
||||
,ii.[PreviousID]
|
||||
,ii.[ContentID]
|
||||
,ii.[DTS]
|
||||
,ii.[UserID]
|
||||
,ii.[LastChanged]
|
||||
,CC.[Number]
|
||||
,CC.[Text]
|
||||
,CC.[Type]
|
||||
,CC.[FormatID]
|
||||
,CC.[Config]
|
||||
,CC.[DTS] [cDTS]
|
||||
,CC.[UserID] [cUserID]
|
||||
,CC.[LastChanged] [cLastChanged]
|
||||
,(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=ii.[ItemID]) [AnnotationCount]
|
||||
,(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=ii.[ItemID]) [DocVersionCount]
|
||||
,(SELECT COUNT(*) FROM [Items] [Next] WHERE [Next].[PreviousID]=ii.[ItemID]) [NextCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=ii.[ItemID]) [PartCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=ii.[ItemID]) [Transition_RangeIDCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=ii.[ItemID]) [Transition_ToIDCount]
|
||||
,(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=CC.[ContentID]) [DetailCount]
|
||||
,(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=CC.[ContentID]) [EntryCount]
|
||||
,(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=CC.[ContentID]) [GridCount]
|
||||
,(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=CC.[ContentID]) [ImageCount]
|
||||
,(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=CC.[ContentID]) [ItemCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=CC.[ContentID]) [cPartCount]
|
||||
,(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=CC.[ContentID]) [RoUsageCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=CC.[ContentID]) [TransitionCount]
|
||||
,(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=CC.[ContentID]) [ZContentCount]
|
||||
,(select dbo.vefn_CheckAllXMLByItemID(ii.itemid,@myxml)) ChkXml
|
||||
FROM [Items] ii
|
||||
INNER JOIN [Contents] cc ON ii.[ContentID] = cc.[ContentID]
|
||||
where ii.ItemID in (select ItemID from @Items)
|
||||
-- order by ii.itemid
|
||||
END
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getRevisionByItemIDandRevisionNumber] Script Date: 11/23/2011 15:58:01 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getRevisionByItemIDandRevisionNumber]
|
||||
|
||||
(
|
||||
@ItemID int,
|
||||
@RevisionNumber nvarchar(50)
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
declare @RevisionID int
|
||||
set @RevisionID = (select revisionid from revisions where itemid = @itemid and revisionnumber = @RevisionNumber)
|
||||
SELECT
|
||||
[RevisionID],
|
||||
[ItemID],
|
||||
[TypeID],
|
||||
[RevisionNumber],
|
||||
[RevisionDate],
|
||||
[Notes],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(*) FROM [Checks] WHERE [Checks].[RevisionID]=[Revisions].[RevisionID]) [CheckCount],
|
||||
(SELECT COUNT(*) FROM [Versions] WHERE [Versions].[RevisionID]=[Revisions].[RevisionID]) [VersionCount]
|
||||
FROM [Revisions]
|
||||
WHERE [RevisionID]=@RevisionID
|
||||
|
||||
SELECT
|
||||
[Checks].[CheckID],
|
||||
[Checks].[RevisionID],
|
||||
[Checks].[StageID],
|
||||
[Checks].[ConsistencyChecks],
|
||||
[Checks].[DTS],
|
||||
[Checks].[UserID],
|
||||
[Checks].[LastChanged],
|
||||
[Stages].[Name] [Stage_Name],
|
||||
[Stages].[Description] [Stage_Description],
|
||||
[Stages].[IsApproved] [Stage_IsApproved],
|
||||
[Stages].[DTS] [Stage_DTS],
|
||||
[Stages].[UserID] [Stage_UserID]
|
||||
FROM [Checks]
|
||||
JOIN [Stages] ON
|
||||
[Stages].[StageID]=[Checks].[StageID]
|
||||
WHERE
|
||||
[Checks].[RevisionID]=@RevisionID
|
||||
|
||||
|
||||
SELECT
|
||||
[Versions].[VersionID],
|
||||
[Versions].[RevisionID],
|
||||
[Versions].[StageID],
|
||||
[Versions].[DTS],
|
||||
[Versions].[UserID],
|
||||
[Versions].[LastChanged],
|
||||
[Versions].[PDF],
|
||||
[Versions].[SummaryPDF],
|
||||
[Stages].[Name] [Stage_Name],
|
||||
[Stages].[Description] [Stage_Description],
|
||||
[Stages].[IsApproved] [Stage_IsApproved],
|
||||
[Stages].[DTS] [Stage_DTS],
|
||||
[Stages].[UserID] [Stage_UserID]
|
||||
FROM [Versions]
|
||||
JOIN [Stages] ON
|
||||
[Stages].[StageID]=[Versions].[StageID]
|
||||
WHERE
|
||||
[Versions].[RevisionID]=@RevisionID
|
||||
|
||||
RETURN
|
||||
go
|
715
PROMS/SQL/3_Approval_SupportProcsFuncs.sql.bak
Normal file
715
PROMS/SQL/3_Approval_SupportProcsFuncs.sql.bak
Normal file
@@ -0,0 +1,715 @@
|
||||
/****** Object: StoredProcedure [dbo].[getTransitionsFromProc] Script Date: 10/21/2011 15:19:55 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
/*
|
||||
getTransitionsFromProc 10
|
||||
*/
|
||||
create PROCEDURE [dbo].[getTransitionsFromProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT tt.[TransitionID]
|
||||
,[FromID]
|
||||
,[ToID]
|
||||
,[RangeID]
|
||||
,[IsRange]
|
||||
,[TranType]
|
||||
,tt.[Config]
|
||||
,tt.[DTS]
|
||||
,tt.[UserID]
|
||||
,tt.[LastChanged]
|
||||
,(SELECT COUNT(*) FROM [ZTransitions] WHERE [ZTransitions].[TransitionID]=[tt].[TransitionID]) [ZTransitionCount]
|
||||
,cc.text ContentText
|
||||
FROM [Transitions] tt
|
||||
inner join contents cc on tt.fromid = cc.contentid
|
||||
WHERE transitionid in (select transitionid from vefn_FindExternalFromTransitions(@ItemID))
|
||||
RETURN
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getTransitionsToProc] Script Date: 10/21/2011 15:24:11 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
/*
|
||||
getTransitionsToProc 10
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[getTransitionsToProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT tt.[TransitionID]
|
||||
,[FromID]
|
||||
,[ToID]
|
||||
,[RangeID]
|
||||
,[IsRange]
|
||||
,[TranType]
|
||||
,tt.[Config]
|
||||
,tt.[DTS]
|
||||
,tt.[UserID]
|
||||
,tt.[LastChanged]
|
||||
,(SELECT COUNT(*) FROM [ZTransitions] WHERE [ZTransitions].[TransitionID]=[tt].[TransitionID]) [ZTransitionCount]
|
||||
,cc.text ContentText
|
||||
FROM [Transitions] tt
|
||||
inner join contents cc on tt.fromid = cc.contentid
|
||||
WHERE transitionid in (select transitionid from vefn_FindExternalTransitions(@ItemID))
|
||||
RETURN
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_FindExternalFromTransitions] Script Date: 10/21/2011 15:27:17 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
Select * from vefn_FindExternalFromTransitions(185)
|
||||
*/
|
||||
|
||||
create FUNCTION [dbo].[vefn_FindExternalFromTransitions](@ItemID int)
|
||||
RETURNS @Children TABLE
|
||||
(
|
||||
[FromItemID] int,
|
||||
[TransitionID] [int] NOT NULL,
|
||||
[FromID] [int] NOT NULL,
|
||||
[ToID] [int] NOT NULL,
|
||||
[RangeID] [int] NOT NULL,
|
||||
[Config] [nvarchar](max) NULL
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
with Itemz([Level], [Ordinal], [ItemID], [PreviousID], [FromType], [ContentID], [DTS], [UserID], [LastChanged],[pContentID], [pDTS],[pUserID],[pLastChanged]) as (
|
||||
Select 0 [Level], 0 [Ordinal], [ItemID], [PreviousID],0 [FromType],[ContentID],[DTS],[UserID],[LastChanged]
|
||||
,0 [pContentID],[DTS] [pDTS], [UserID] [pUserID], [LastChanged] [pLastChanged]
|
||||
FROM [Items]
|
||||
where [ItemID]=@ItemID
|
||||
Union All
|
||||
-- Children
|
||||
select [Level] + 1,0, I.[ItemID], I.[PreviousID], P.[FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,P.[ContentID] [pContentID],P.[DTS] [pDTS],P.[UserID] [pUserID],P.[LastChanged] [pLastChanged]
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
-- Siblings
|
||||
Union All
|
||||
select [Level] ,Z.[Ordinal] +1, I.[ItemID], I.[PreviousID], [FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,null,null,null,null
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
where Z.[Level] > 0
|
||||
)
|
||||
insert into @Children
|
||||
select ItemID [FromItemID], TT.[TransitionID], TT.[FromID], TT.[ToID], TT.[RangeID], TT.[Config]
|
||||
from Transitions TT
|
||||
join Items II on II.ContentID=TT.FromID
|
||||
where (ToID not in(select ItemID from Itemz) OR RangeID not in(select ItemID from Itemz))
|
||||
AND FromID in(Select ContentID from ItemZ)
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getLibDocsForProc] Script Date: 10/21/2011 15:28:43 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
/*
|
||||
getLibDocsForProc 10
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[getLibDocsForProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT dd.[DocID]
|
||||
,[LibTitle]
|
||||
,[DocContent]
|
||||
,[DocAscii]
|
||||
,[Config]
|
||||
,dd.[DTS]
|
||||
,dd.[UserID]
|
||||
,dd.[LastChanged]
|
||||
,[FileExtension],
|
||||
(SELECT COUNT(*) FROM [DROUsages] WHERE [DROUsages].[DocID]=[dd].[DocID]) [DROUsageCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[DocID]=[dd].[DocID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Pdfs] WHERE [Pdfs].[DocID]=[dd].[DocID]) [PdfCount]
|
||||
|
||||
FROM [Documents] dd
|
||||
INNER JOIN [Entries] ee on dd.docid = ee.docid
|
||||
INNER JOIN vefn_ChildItems(@ItemID) cc on cc.contentid = ee.contentid
|
||||
RETURN
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getRoUsagesForProc] Script Date: 10/21/2011 15:31:51 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER OFF
|
||||
GO
|
||||
|
||||
create PROCEDURE [dbo].[getRoUsagesForProc]
|
||||
(
|
||||
@ItemID int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[ROUsageID],
|
||||
rr.[ContentID],
|
||||
[ROID],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
[RODbID]
|
||||
FROM [RoUsages] rr
|
||||
INNER JOIN vefn_ChildItems(@ItemID) cc on cc.contentid = rr.contentid
|
||||
RETURN
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_CheckXML] Script Date: 10/25/2011 18:36:53 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
declare @NewXML xml
|
||||
select @NewXML = consistencychecks from checks where checkid = 48
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'2011-08-24T11:20:57.027','2011-12-25T00:00:00.000') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'88%','88.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'="6%','="6.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'23%','23.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),'90%','90.12345%') as xml)
|
||||
set @NewXML = cast(replace(cast(@NewXML as varchar(max)),', Step 13',', Step 14') as xml)r
|
||||
declare @OldXML xml
|
||||
select @OldXML = consistencychecks from checks where checkid = 1
|
||||
--select .dbo.vefn_CheckXML(@NewXML, @OldXML)
|
||||
select ii.*,ss.*,.dbo.vefn_CheckXML(@NewXML, consistencychecks) chkxml from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
inner join items ii on rr.itemid = ii.itemid
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
*/
|
||||
CREATE function [dbo].[vefn_CheckXML](@NewXML xml, @OldXML xml)
|
||||
returns xml
|
||||
begin
|
||||
declare @ChkXML xml
|
||||
set @ChkXML =
|
||||
(
|
||||
select
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ah.ROID,OldROValue,ROValue from
|
||||
(
|
||||
select r1.value('@ROID','varchar(20)') roid,r1.value('@ROValue','varchar(max)') oldrovalue
|
||||
from @OldXML.nodes('//ROCheck') as t1(r1)
|
||||
) ah
|
||||
inner join
|
||||
(
|
||||
select distinct r2.value('@ROID','varchar(20)') roid,r2.value('@ROValue','varchar(max)') rovalue
|
||||
from @NewXML.nodes('//ROCheck') as t2(r2)
|
||||
) ds
|
||||
on ah.roid = ds.roid
|
||||
and oldrovalue != rovalue
|
||||
) ROCheck
|
||||
for xml auto,root('ROChecks'),type
|
||||
)
|
||||
,
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ah.TransitionID,OldTransitionValue,TransitionValue from
|
||||
(
|
||||
select r1.value('@TransitionID','int') TransitionID,r1.value('@TransitionValue','varchar(max)') OldTransitionValue
|
||||
from @OldXML.nodes('//TransitionCheck') as t1(r1)
|
||||
) ah
|
||||
inner join
|
||||
(
|
||||
select distinct r2.value('@TransitionID','int') TransitionID,r2.value('@TransitionValue','varchar(max)') TransitionValue
|
||||
from @NewXML.nodes('//TransitionCheck') as t2(r2)
|
||||
) ds
|
||||
on ah.TransitionID = ds.TransitionID
|
||||
and OldTransitionValue != TransitionValue
|
||||
) TransitionCheck
|
||||
for xml auto,root('TransitionChecks'),type
|
||||
)
|
||||
,
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ah.DocID,OldDocDate,DocDate from
|
||||
(
|
||||
select r1.value('@DocID','int') docid,r1.value('@DocDate','datetime') olddocdate
|
||||
from @OldXML.nodes('//LibDocCheck') as t1(r1)
|
||||
) ah
|
||||
inner join
|
||||
(
|
||||
select distinct r2.value('@DocID','int') docid,r2.value('@DocDate','datetime') docdate
|
||||
from @NewXML.nodes('//LibDocCheck') as t2(r2)
|
||||
) ds
|
||||
on ah.docid = ds.docid
|
||||
and olddocdate != docdate
|
||||
) LibDocCheck
|
||||
for xml auto,root('LibDocChecks'),type
|
||||
)
|
||||
for xml path(''),ROOT ('ConsistencyChecks'),type
|
||||
)
|
||||
return @ChkXML
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_CheckAllXML] Script Date: 10/21/2011 15:00:56 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
select [dbo].[vefn_CheckAllXML](1)
|
||||
*/
|
||||
CREATE function [dbo].[vefn_CheckAllXML](@DocVersionID int)
|
||||
returns xml
|
||||
begin
|
||||
declare @ChkXML xml
|
||||
set @ChkXML =
|
||||
(
|
||||
select
|
||||
(--ro inconsistencies accross set
|
||||
select ItemID,ROID,ROValue from
|
||||
(
|
||||
select rr.itemid,r1.value('@ROID','varchar(max)') roid,r1.value('@ROValue','varchar(max)') rovalue
|
||||
from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
cross apply cc.consistencychecks.nodes('//ROCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
and rr.itemid in (select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
) ROCheck
|
||||
where roid in
|
||||
(
|
||||
--get roids that has more than 1 rovalue from distinct roid and rovalue from checks for latest checkid with approved stage for each itemid
|
||||
select roid from
|
||||
(
|
||||
--distinct roid and rovalue from checks for latest checkid with approved stage for each itemid
|
||||
select distinct r1.value('@ROID','varchar(max)') roid,r1.value('@ROValue','varchar(max)') rovalue
|
||||
from checks cc
|
||||
cross apply cc.consistencychecks.nodes('//ROCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
) t1
|
||||
group by roid having count(*) > 1
|
||||
)
|
||||
order by itemid
|
||||
for xml auto,root('ROChecks'),type
|
||||
),
|
||||
--jcb
|
||||
(--transition inconsistencies accross set
|
||||
select ItemID,TransitionID,TransitionValue from
|
||||
(
|
||||
select rr.itemid,r1.value('@TransitionID','int') transitionid,r1.value('@TransitionValue','varchar(max)') transitionvalue
|
||||
from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
cross apply cc.consistencychecks.nodes('//TransitionCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
and rr.itemid in (select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
) TransitionCheck
|
||||
where transitionid in
|
||||
(
|
||||
--get transitionids that has more than 1 transitionvalue from distinct transitionid and transitionvalue from checks for latest checkid with approved stage for each itemid
|
||||
select transitionid from
|
||||
(
|
||||
--distinct docid and docdate from checks for latest checkid with approved stage for each itemid
|
||||
select distinct r1.value('@TransitionID','int') transitionid,r1.value('@TransitionValue','varchar(max)') transitionvalue
|
||||
from checks cc
|
||||
cross apply cc.consistencychecks.nodes('//TransitionCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
) t1
|
||||
group by transitionid having count(*) > 1
|
||||
)
|
||||
order by itemid
|
||||
for xml auto,root('TransitionChecks'),type
|
||||
),
|
||||
--end jcb
|
||||
(--libdoc inconsistencies accross set
|
||||
select ItemID,DocID,DocDate from
|
||||
(
|
||||
select rr.itemid,r1.value('@DocID','int') docid,r1.value('@DocDate','datetime') docdate
|
||||
from checks cc
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
cross apply cc.consistencychecks.nodes('//LibDocCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
and rr.itemid in (select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
) LibDocCheck
|
||||
where docid in
|
||||
(
|
||||
--get docids that has more than 1 docdate from distinct docid and docdate from checks for latest checkid with approved stage for each itemid
|
||||
select docid from
|
||||
(
|
||||
--distinct docid and docdate from checks for latest checkid with approved stage for each itemid
|
||||
select distinct r1.value('@DocID','int') docid,r1.value('@DocDate','datetime') docdate
|
||||
from checks cc
|
||||
cross apply cc.consistencychecks.nodes('//LibDocCheck') t1(r1)
|
||||
where cc.checkid in
|
||||
--latest checkid with approved stage for each itemid
|
||||
(
|
||||
select max(cc.checkid) checkid
|
||||
from checks cc
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
inner join revisions rr on cc.revisionid = rr.revisionid
|
||||
where ss.isapproved = 1
|
||||
group by rr.itemid
|
||||
)
|
||||
) t1
|
||||
group by docid having count(*) > 1
|
||||
)
|
||||
order by itemid
|
||||
for xml auto,root('LibDocChecks'),type
|
||||
)
|
||||
for xml path(''),ROOT ('ConsistencyChecks'),type
|
||||
)
|
||||
return @ChkXML
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_CheckAllXMLByItemID] Script Date: 10/21/2011 15:01:32 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
declare @myxml xml
|
||||
set @myxml = (select dbo.vefn_checkallxml(1))
|
||||
select dbo.vefn_checkallxmlbyitemid(1,@myxml)
|
||||
*/
|
||||
CREATE function [dbo].[vefn_CheckAllXMLByItemID](@ItemID int,@MyXml xml)
|
||||
returns xml
|
||||
begin
|
||||
declare @ChkXML xml
|
||||
declare @ROCheck table
|
||||
(
|
||||
ItemID int,
|
||||
ROID varchar(max),
|
||||
ROValue varchar(max)
|
||||
)
|
||||
insert into @ROCheck
|
||||
select r2.value('@ItemID','int'),r2.value('@ROID','varchar(max)'),r2.value('@ROValue','varchar(max)')
|
||||
from @MyXml.nodes('//ROCheck') t2(r2)
|
||||
--jcb
|
||||
declare @TransitionCheck table
|
||||
(
|
||||
ItemID int,
|
||||
TransitionID int,
|
||||
TransitionValue varchar(max)
|
||||
)
|
||||
insert into @TransitionCheck
|
||||
select r2.value('@ItemID','int'),r2.value('@TransitionID','int'),r2.value('@TransitionValue','varchar(max)')
|
||||
from @MyXml.nodes('//TransitionCheck') t2(r2)
|
||||
--end jcb
|
||||
declare @LibDocCheck table
|
||||
(
|
||||
ItemID int,
|
||||
DocID int,
|
||||
DocDate datetime
|
||||
)
|
||||
insert into @LibDocCheck
|
||||
select r2.value('@ItemID','int'),r2.value('@DocID','int'),r2.value('@DocDate','datetime')
|
||||
from @MyXml.nodes('//LibDocCheck') t2(r2)
|
||||
set @ChkXML =
|
||||
(
|
||||
select
|
||||
(select * from @ROCheck ROCheck where itemid = @ItemID for xml auto, root('ROChecks'),type),
|
||||
(select * from @TransitionCheck TransitionCheck where itemid = @ItemID for xml auto, root('TransitionChecks'),type),
|
||||
(select * from @LibDocCheck LibDocCheck where itemid = @ItemID for xml auto, root('LibDocChecks'),type)
|
||||
for xml path(''),ROOT ('ConsistencyChecks'),type
|
||||
)
|
||||
return @ChkXML
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_GetConsistencyCheckProcedures] Script Date: 10/25/2011 18:38:25 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
declare @myxml xml
|
||||
select @myxml = consistencychecks from checks where checkid = 2
|
||||
declare @docversionid int
|
||||
set @docversionid = 1
|
||||
exec vesp_GetConsistencyCheckProcedures @docversionid, @myxml
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[vesp_GetConsistencyCheckProcedures]
|
||||
(
|
||||
@DocVersionID int,
|
||||
@MyXml xml
|
||||
)
|
||||
AS BEGIN
|
||||
--to be removed
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'2011-08-24T11:20:57.027','2011-12-25T00:00:00.000') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'88%','88.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'="6%','="6.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'23%','23.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),'90%','90.12345%') as xml)
|
||||
-- set @myxml = cast(replace(cast(@myxml as varchar(max)),', Step 13',', Step 14') as xml)
|
||||
--end to be removed
|
||||
DECLARE @Items TABLE
|
||||
(
|
||||
ID int identity(1,1),
|
||||
ItemID int
|
||||
)
|
||||
INSERT INTO @Items (itemid)
|
||||
select roc.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//ConsistencyChecks') t1(roc)
|
||||
declare @LatestApproved TABLE
|
||||
(
|
||||
ItemID int PRIMARY KEY,
|
||||
CheckID int
|
||||
)
|
||||
insert into @LatestApproved
|
||||
select rr.itemid,max(checkid) checkid
|
||||
from revisions rr
|
||||
inner join checks cc on rr.revisionid = cc.revisionid
|
||||
inner join stages ss on cc.stageid = ss.stageid
|
||||
where ss.isapproved = 1
|
||||
and rr.itemid in
|
||||
(select itemid from vefn_siblingitems((select itemid from docversions where versionid = @docversionid),0))
|
||||
group by rr.itemid
|
||||
|
||||
SELECT
|
||||
ii.[ItemID]
|
||||
,ii.[PreviousID]
|
||||
,ii.[ContentID]
|
||||
,ii.[DTS]
|
||||
,ii.[UserID]
|
||||
,ii.[LastChanged]
|
||||
,CC.[Number]
|
||||
,CC.[Text]
|
||||
,CC.[Type]
|
||||
,CC.[FormatID]
|
||||
,CC.[Config]
|
||||
,CC.[DTS] [cDTS]
|
||||
,CC.[UserID] [cUserID]
|
||||
,CC.[LastChanged] [cLastChanged]
|
||||
,(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=ii.[ItemID]) [AnnotationCount]
|
||||
,(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=ii.[ItemID]) [DocVersionCount]
|
||||
,(SELECT COUNT(*) FROM [Items] [Next] WHERE [Next].[PreviousID]=ii.[ItemID]) [NextCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=ii.[ItemID]) [PartCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=ii.[ItemID]) [Transition_RangeIDCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=ii.[ItemID]) [Transition_ToIDCount]
|
||||
,(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=CC.[ContentID]) [DetailCount]
|
||||
,(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=CC.[ContentID]) [EntryCount]
|
||||
,(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=CC.[ContentID]) [GridCount]
|
||||
,(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=CC.[ContentID]) [ImageCount]
|
||||
,(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=CC.[ContentID]) [ItemCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=CC.[ContentID]) [cPartCount]
|
||||
,(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=CC.[ContentID]) [RoUsageCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=CC.[ContentID]) [TransitionCount]
|
||||
,(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=CC.[ContentID]) [ZContentCount]
|
||||
,ribeye.ChkXml
|
||||
FROM [Items] ii
|
||||
INNER JOIN [Contents] cc ON ii.[ContentID] = cc.[ContentID]
|
||||
inner join
|
||||
(
|
||||
select la.itemid,.dbo.vefn_checkxml(@myxml,cc.consistencychecks) chkxml
|
||||
from checks cc
|
||||
inner join @LatestApproved la on cc.checkid = la.checkid
|
||||
) ribeye on ii.itemid = ribeye.itemid
|
||||
left join @items iii on ii.itemid = iii.itemid
|
||||
where chkxml.exist('//ROChecks') | chkxml.exist('//TransitionChecks') | chkxml.exist('//LibDocChecks') > 0 or
|
||||
ii.ItemID in (select ItemID from @Items)
|
||||
order by isnull(iii.id,999999)
|
||||
END
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_GetAllConsistencyIssues] Script Date: 10/21/2011 15:03:40 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
[dbo].[vesp_GetAllConsistencyIssues] 1
|
||||
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[vesp_GetAllConsistencyIssues]
|
||||
(
|
||||
@DocVersionID int
|
||||
)
|
||||
AS BEGIN
|
||||
declare @myxml xml
|
||||
set @myxml = (select dbo.vefn_checkallxml(@DocVersionID))
|
||||
DECLARE @Items TABLE
|
||||
(
|
||||
ItemID int PRIMARY KEY
|
||||
)
|
||||
INSERT INTO @Items
|
||||
select r1.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//ROCheck') t1(r1)
|
||||
union
|
||||
select r1.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//TransitionCheck') t1(r1)
|
||||
union
|
||||
select r1.value('@ItemID','int') itemid
|
||||
from @myxml.nodes('//LibDocCheck') t1(r1)
|
||||
SELECT
|
||||
ii.[ItemID]
|
||||
,ii.[PreviousID]
|
||||
,ii.[ContentID]
|
||||
,ii.[DTS]
|
||||
,ii.[UserID]
|
||||
,ii.[LastChanged]
|
||||
,CC.[Number]
|
||||
,CC.[Text]
|
||||
,CC.[Type]
|
||||
,CC.[FormatID]
|
||||
,CC.[Config]
|
||||
,CC.[DTS] [cDTS]
|
||||
,CC.[UserID] [cUserID]
|
||||
,CC.[LastChanged] [cLastChanged]
|
||||
,(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=ii.[ItemID]) [AnnotationCount]
|
||||
,(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=ii.[ItemID]) [DocVersionCount]
|
||||
,(SELECT COUNT(*) FROM [Items] [Next] WHERE [Next].[PreviousID]=ii.[ItemID]) [NextCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=ii.[ItemID]) [PartCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=ii.[ItemID]) [Transition_RangeIDCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=ii.[ItemID]) [Transition_ToIDCount]
|
||||
,(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=CC.[ContentID]) [DetailCount]
|
||||
,(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=CC.[ContentID]) [EntryCount]
|
||||
,(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=CC.[ContentID]) [GridCount]
|
||||
,(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=CC.[ContentID]) [ImageCount]
|
||||
,(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=CC.[ContentID]) [ItemCount]
|
||||
,(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=CC.[ContentID]) [cPartCount]
|
||||
,(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=CC.[ContentID]) [RoUsageCount]
|
||||
,(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=CC.[ContentID]) [TransitionCount]
|
||||
,(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=CC.[ContentID]) [ZContentCount]
|
||||
,(select dbo.vefn_CheckAllXMLByItemID(ii.itemid,@myxml)) ChkXml
|
||||
FROM [Items] ii
|
||||
INNER JOIN [Contents] cc ON ii.[ContentID] = cc.[ContentID]
|
||||
where ii.ItemID in (select ItemID from @Items)
|
||||
-- order by ii.itemid
|
||||
END
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getRevisionByItemIDandRevisionNumber] Script Date: 11/23/2011 15:54:02 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getRevisionByItemIDandRevisionNumber]
|
||||
|
||||
(
|
||||
@ItemID int,
|
||||
@RevisionNumber nvarchar(50)
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
declare @RevisionID int
|
||||
set @RevisionID = (select revisionid from revisions where itemid = @itemid and revisionnumber = @RevisionNumber)
|
||||
SELECT
|
||||
[RevisionID],
|
||||
[ItemID],
|
||||
[TypeID],
|
||||
[RevisionNumber],
|
||||
[RevisionDate],
|
||||
[Notes],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(*) FROM [Checks] WHERE [Checks].[RevisionID]=[Revisions].[RevisionID]) [CheckCount],
|
||||
(SELECT COUNT(*) FROM [Versions] WHERE [Versions].[RevisionID]=[Revisions].[RevisionID]) [VersionCount]
|
||||
FROM [Revisions]
|
||||
WHERE [RevisionID]=@RevisionID
|
||||
|
||||
SELECT
|
||||
[Checks].[CheckID],
|
||||
[Checks].[RevisionID],
|
||||
[Checks].[StageID],
|
||||
[Checks].[ConsistencyChecks],
|
||||
[Checks].[DTS],
|
||||
[Checks].[UserID],
|
||||
[Checks].[LastChanged],
|
||||
[Stages].[Name] [Stage_Name],
|
||||
[Stages].[Description] [Stage_Description],
|
||||
[Stages].[IsApproved] [Stage_IsApproved],
|
||||
[Stages].[DTS] [Stage_DTS],
|
||||
[Stages].[UserID] [Stage_UserID]
|
||||
FROM [Checks]
|
||||
JOIN [Stages] ON
|
||||
[Stages].[StageID]=[Checks].[StageID]
|
||||
WHERE
|
||||
[Checks].[RevisionID]=@RevisionID
|
||||
|
||||
|
||||
SELECT
|
||||
[Versions].[VersionID],
|
||||
[Versions].[RevisionID],
|
||||
[Versions].[StageID],
|
||||
[Versions].[DTS],
|
||||
[Versions].[UserID],
|
||||
[Versions].[PDF],
|
||||
[Versions].[SummaryPDF],
|
||||
[Stages].[Name] [Stage_Name],
|
||||
[Stages].[Description] [Stage_Description],
|
||||
[Stages].[IsApproved] [Stage_IsApproved],
|
||||
[Stages].[DTS] [Stage_DTS],
|
||||
[Stages].[UserID] [Stage_UserID]
|
||||
FROM [Versions]
|
||||
JOIN [Stages] ON
|
||||
[Stages].[StageID]=[Versions].[StageID]
|
||||
WHERE
|
||||
[Versions].[RevisionID]=@RevisionID
|
||||
|
||||
RETURN
|
||||
|
171
PROMS/SQL/4_Fix_Chronology_Summary_Data.sql
Normal file
171
PROMS/SQL/4_Fix_Chronology_Summary_Data.sql
Normal file
@@ -0,0 +1,171 @@
|
||||
/****** Object: StoredProcedure [dbo].[getAnnotationAuditsChronologyByItemID] Script Date: 10/28/2011 17:32:18 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getAnnotationAuditsChronologyByItemID] ******/
|
||||
/*
|
||||
getAnnotationAuditsChronologyByItemID 3,1230
|
||||
getAnnotationAuditsChronologyByItemID 30,8570
|
||||
getAnnotationAuditsChronologyByItemID 30,8513
|
||||
getAnnotationAuditsChronologyByItemID 30,8505
|
||||
*/
|
||||
ALTER procedure [dbo].[getAnnotationAuditsChronologyByItemID]
|
||||
(
|
||||
@ProcItemID int,
|
||||
@ItemID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
select
|
||||
case
|
||||
when lastauditid is null and dts > itemdts then 'Added'
|
||||
when deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end ActionWhat
|
||||
,case
|
||||
when lastauditid is null and dts > itemdts then dts
|
||||
when deletestatus > 0 then ActionDTS
|
||||
when lastauditid = deletedauditid then ActionDTS
|
||||
else dts
|
||||
end ActionWhen
|
||||
,*
|
||||
from
|
||||
(
|
||||
select
|
||||
cast(ident_current('annotationaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from annotationaudits) auditid
|
||||
-- 0 auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,0 deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
from tblannotations aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
where aa.deletestatus = 0
|
||||
union
|
||||
select
|
||||
aa.auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,aa.deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid ) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
from annotationaudits aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
) ah
|
||||
where itemid in (select itemid from vefn_tblchilditems (@procitemid,@itemid,0))
|
||||
and dts > (select dts from versions where versionid = (select max(versionid) from revisions rr inner join versions vv on rr.revisionid = vv.revisionid
|
||||
inner join stages ss on vv.stageid = ss.stageid where itemid = @procitemid and ss.isapproved = 1))
|
||||
order by annotationid,auditid--actionwhen
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 10/28/2011 18:22:23 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
select * from vefn_chronologyreport(41)
|
||||
*/
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 05/18/2011 11:20:48 ******/
|
||||
ALTER function [dbo].[vefn_ChronologyReport](@ProcItemID int)
|
||||
returns @Report table
|
||||
(
|
||||
AuditID bigint,
|
||||
ContentID int,
|
||||
Number nvarchar(512),
|
||||
Text nvarchar(max),
|
||||
Type int,
|
||||
FormatID int,
|
||||
Config nvarchar(max),
|
||||
DTS datetime,
|
||||
UserID nvarchar(200),
|
||||
DeleteStatus int,
|
||||
ActionDTS datetime,
|
||||
ItemDTS datetime,
|
||||
LastAuditID int,
|
||||
DeletedAuditID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
insert into @Report
|
||||
select * from
|
||||
(
|
||||
SELECT
|
||||
[AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM ContentAudits ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
where Number is not null
|
||||
--added jcb 20111028_1827
|
||||
and ca.contentid != (select contentid from items where itemid = @procitemid)
|
||||
--end added jcb 20111028_1827
|
||||
UNION
|
||||
SELECT
|
||||
cast(ident_current('contentaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from contentaudits) [AuditID]
|
||||
-- 0 [AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM tblContents ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
WHERE ca.DeleteStatus = 0 AND
|
||||
--added jcb 20111028_1827
|
||||
ca.contentid != (select contentid from items where itemid = @procitemid) and
|
||||
--end added jcb 20111028_1827
|
||||
ca.ContentID in (SELECT [ContentID] FROM ContentAudits)
|
||||
) ah
|
||||
where cadts > (select dts from versions where versionid = (select max(versionid) from revisions rr inner join versions vv on rr.revisionid = vv.revisionid
|
||||
inner join stages ss on vv.stageid = ss.stageid where itemid = @procitemid and ss.isapproved = 1))
|
||||
order by cadts,ActionDTS
|
||||
return
|
||||
end
|
||||
go
|
169
PROMS/SQL/4_Fix_Chronology_Summary_Data.sql.bak
Normal file
169
PROMS/SQL/4_Fix_Chronology_Summary_Data.sql.bak
Normal file
@@ -0,0 +1,169 @@
|
||||
/****** Object: StoredProcedure [dbo].[getAnnotationAuditsChronologyByItemID] Script Date: 10/28/2011 17:32:18 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getAnnotationAuditsChronologyByItemID] ******/
|
||||
/*
|
||||
getAnnotationAuditsChronologyByItemID 3,1230
|
||||
getAnnotationAuditsChronologyByItemID 30,8570
|
||||
getAnnotationAuditsChronologyByItemID 30,8513
|
||||
getAnnotationAuditsChronologyByItemID 30,8505
|
||||
*/
|
||||
ALTER procedure [dbo].[getAnnotationAuditsChronologyByItemID]
|
||||
(
|
||||
@ProcItemID int,
|
||||
@ItemID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
select
|
||||
case
|
||||
when lastauditid is null and dts > itemdts then 'Added'
|
||||
when deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end ActionWhat
|
||||
,case
|
||||
when lastauditid is null and dts > itemdts then dts
|
||||
when deletestatus > 0 then ActionDTS
|
||||
when lastauditid = deletedauditid then ActionDTS
|
||||
else dts
|
||||
end ActionWhen
|
||||
,*
|
||||
from
|
||||
(
|
||||
select
|
||||
cast(ident_current('annotationaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from annotationaudits) auditid
|
||||
-- 0 auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,0 deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
from tblannotations aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
where aa.deletestatus = 0
|
||||
union
|
||||
select
|
||||
aa.auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,aa.deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid ) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
from annotationaudits aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
) ah
|
||||
where itemid in (select itemid from vefn_tblchilditems (@procitemid,@itemid,0))
|
||||
and dts > (select dts from items where itemid = @procitemid)
|
||||
order by annotationid,auditid--actionwhen
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 10/28/2011 18:22:23 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
select * from vefn_chronologyreport(41)
|
||||
*/
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 05/18/2011 11:20:48 ******/
|
||||
ALTER function [dbo].[vefn_ChronologyReport](@ProcItemID int)
|
||||
returns @Report table
|
||||
(
|
||||
AuditID bigint,
|
||||
ContentID int,
|
||||
Number nvarchar(512),
|
||||
Text nvarchar(max),
|
||||
Type int,
|
||||
FormatID int,
|
||||
Config nvarchar(max),
|
||||
DTS datetime,
|
||||
UserID nvarchar(200),
|
||||
DeleteStatus int,
|
||||
ActionDTS datetime,
|
||||
ItemDTS datetime,
|
||||
LastAuditID int,
|
||||
DeletedAuditID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
insert into @Report
|
||||
select * from
|
||||
(
|
||||
SELECT
|
||||
[AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM ContentAudits ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
where Number is not null
|
||||
--added jcb 20111028_1827
|
||||
and ca.contentid != (select contentid from items where itemid = @procitemid)
|
||||
--end added jcb 20111028_1827
|
||||
UNION
|
||||
SELECT
|
||||
cast(ident_current('contentaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from contentaudits) [AuditID]
|
||||
-- 0 [AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM tblContents ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
WHERE ca.DeleteStatus = 0 AND
|
||||
--added jcb 20111028_1827
|
||||
ca.contentid != (select contentid from items where itemid = @procitemid) and
|
||||
--end added jcb 20111028_1827
|
||||
ca.ContentID in (SELECT [ContentID] FROM ContentAudits)
|
||||
) ah
|
||||
where cadts > (select dts from items where itemid = @ProcItemID)
|
||||
order by cadts,ActionDTS
|
||||
return
|
||||
end
|
||||
go
|
377
PROMS/SQL/5_Approval_Past_History_Changes.sql
Normal file
377
PROMS/SQL/5_Approval_Past_History_Changes.sql
Normal file
@@ -0,0 +1,377 @@
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReportPast] Script Date: 11/01/2011 18:14:34 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
select * from vefn_chronologyreportpast(41)
|
||||
*/
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReportPast] Script Date: 05/18/2011 11:20:48 ******/
|
||||
create function [dbo].[vefn_ChronologyReportPast](@ProcItemID int)
|
||||
returns @Report table
|
||||
(
|
||||
AuditID bigint,
|
||||
ContentID int,
|
||||
Number nvarchar(512),
|
||||
Text nvarchar(max),
|
||||
Type int,
|
||||
FormatID int,
|
||||
Config nvarchar(max),
|
||||
DTS datetime,
|
||||
UserID nvarchar(200),
|
||||
DeleteStatus int,
|
||||
ActionDTS datetime,
|
||||
ItemDTS datetime,
|
||||
LastAuditID int,
|
||||
DeletedAuditID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
insert into @Report
|
||||
select * from
|
||||
(
|
||||
SELECT
|
||||
[AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM ContentAudits ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
where Number is not null
|
||||
--added jcb 20111028_1827
|
||||
and ca.contentid != (select contentid from items where itemid = @procitemid)
|
||||
--end added jcb 20111028_1827
|
||||
UNION
|
||||
SELECT
|
||||
cast(ident_current('contentaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from contentaudits) [AuditID]
|
||||
-- 0 [AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM tblContents ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
WHERE ca.DeleteStatus = 0 AND
|
||||
--added jcb 20111028_1827
|
||||
ca.contentid != (select contentid from items where itemid = @procitemid) and
|
||||
--end added jcb 20111028_1827
|
||||
ca.ContentID in (SELECT [ContentID] FROM ContentAudits)
|
||||
) ah
|
||||
where cadts <= (select dts from items where itemid = @ProcItemID)
|
||||
order by cadts,ActionDTS
|
||||
return
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getContentAuditsChronologyPastByItemID] Script Date: 11/01/2011 18:13:57 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getContentAuditsChronologyPastByItemID] ******/
|
||||
/*
|
||||
getContentAuditsChronologyPastByItemID 146,146,0
|
||||
getContentAuditsChronologyPastByItemID 41,41,0
|
||||
getContentAuditsChronologyPastByItemID 9,9,0
|
||||
getContentAuditsChronologyPastByItemID 146,146,1
|
||||
*/
|
||||
create PROCEDURE [dbo].[getContentAuditsChronologyPastByItemID]
|
||||
(
|
||||
@ProcedureItemID int,
|
||||
@SelectedItemID int,
|
||||
@IncludeDeletedChildren int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
order by OrdinalPath, contentid,auditid--actionwhen
|
||||
RETURN
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getContentAuditsSummaryPastByItemID] Script Date: 11/01/2011 18:17:56 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getContentAuditsSummaryPastByItemID] ******/
|
||||
/*
|
||||
getContentAuditsSummaryPastByItemID 146,146,0
|
||||
getContentAuditsSummaryPastByItemID 41,41,0
|
||||
getContentAuditsSummaryPastByItemID 9,9,0
|
||||
getContentAuditsSummaryPastByItemID 146,146,1
|
||||
*/
|
||||
create PROCEDURE [dbo].[getContentAuditsSummaryPastByItemID]
|
||||
(
|
||||
@ProcedureItemID int,
|
||||
@SelectedItemID int,
|
||||
@IncludeDeletedChildren int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
|
||||
select z.* from
|
||||
(
|
||||
select contentid,min(auditid) auditid from
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) x
|
||||
group by contentid
|
||||
) y
|
||||
inner join
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID,ordinalpath
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) z on y.contentid = z.contentid and y.auditid = z.auditid
|
||||
union
|
||||
select z.* from
|
||||
(
|
||||
select contentid,max(auditid) auditid from
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) x
|
||||
group by contentid
|
||||
) y
|
||||
inner join
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID,ordinalpath
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) z on y.contentid = z.contentid and y.auditid = z.auditid
|
||||
order by OrdinalPath, contentid,auditid--actionwhen
|
||||
RETURN
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getAnnotationAuditsChronologyByItemID] Script Date: 11/01/2011 21:31:02 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getAnnotationAuditsChronologyPastByItemID] ******/
|
||||
/*
|
||||
getAnnotationAuditsChronologyPastByItemID 3,1230
|
||||
getAnnotationAuditsChronologyPastByItemID 30,8570
|
||||
getAnnotationAuditsChronologyPastByItemID 30,8513
|
||||
getAnnotationAuditsChronologyPastByItemID 30,8505
|
||||
*/
|
||||
create procedure [dbo].[getAnnotationAuditsChronologyPastByItemID]
|
||||
(
|
||||
@ProcItemID int,
|
||||
@ItemID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
select
|
||||
case
|
||||
when lastauditid is null and dts > itemdts then 'Added'
|
||||
when deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end ActionWhat
|
||||
,case
|
||||
when lastauditid is null and dts > itemdts then dts
|
||||
when deletestatus > 0 then ActionDTS
|
||||
when lastauditid = deletedauditid then ActionDTS
|
||||
else dts
|
||||
end ActionWhen
|
||||
,*
|
||||
from
|
||||
(
|
||||
select
|
||||
cast(ident_current('annotationaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from annotationaudits) auditid
|
||||
-- 0 auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,0 deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
from tblannotations aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
where aa.deletestatus = 0
|
||||
union
|
||||
select
|
||||
aa.auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,aa.deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid ) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
from annotationaudits aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
) ah
|
||||
where itemid in (select itemid from vefn_tblchilditems (@procitemid,@itemid,0))
|
||||
and dts <= (select dts from items where itemid = @procitemid)
|
||||
order by annotationid,auditid--actionwhen
|
||||
end
|
||||
go
|
293
PROMS/SQL/5_Approval_Past_History_Changes.sql.bak
Normal file
293
PROMS/SQL/5_Approval_Past_History_Changes.sql.bak
Normal file
@@ -0,0 +1,293 @@
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReportPast] Script Date: 11/01/2011 18:14:34 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
select * from vefn_chronologyreportpast(41)
|
||||
*/
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReportPast] Script Date: 05/18/2011 11:20:48 ******/
|
||||
create function [dbo].[vefn_ChronologyReportPast](@ProcItemID int)
|
||||
returns @Report table
|
||||
(
|
||||
AuditID bigint,
|
||||
ContentID int,
|
||||
Number nvarchar(512),
|
||||
Text nvarchar(max),
|
||||
Type int,
|
||||
FormatID int,
|
||||
Config nvarchar(max),
|
||||
DTS datetime,
|
||||
UserID nvarchar(200),
|
||||
DeleteStatus int,
|
||||
ActionDTS datetime,
|
||||
ItemDTS datetime,
|
||||
LastAuditID int,
|
||||
DeletedAuditID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
insert into @Report
|
||||
select * from
|
||||
(
|
||||
SELECT
|
||||
[AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and ca.auditid > auditid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM ContentAudits ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
where Number is not null
|
||||
--added jcb 20111028_1827
|
||||
and ca.contentid != (select contentid from items where itemid = @procitemid)
|
||||
--end added jcb 20111028_1827
|
||||
UNION
|
||||
SELECT
|
||||
cast(ident_current('contentaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from contentaudits) [AuditID]
|
||||
-- 0 [AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null) LastAuditID
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM tblContents ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
WHERE ca.DeleteStatus = 0 AND
|
||||
--added jcb 20111028_1827
|
||||
ca.contentid != (select contentid from items where itemid = @procitemid) and
|
||||
--end added jcb 20111028_1827
|
||||
ca.ContentID in (SELECT [ContentID] FROM ContentAudits)
|
||||
) ah
|
||||
where cadts <= (select dts from items where itemid = @ProcItemID)
|
||||
order by cadts,ActionDTS
|
||||
return
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getContentAuditsChronologyPastByItemID] Script Date: 11/01/2011 18:13:57 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getContentAuditsChronologyPastByItemID] ******/
|
||||
/*
|
||||
getContentAuditsChronologyPastByItemID 146,146,0
|
||||
getContentAuditsChronologyPastByItemID 41,41,0
|
||||
getContentAuditsChronologyPastByItemID 9,9,0
|
||||
getContentAuditsChronologyPastByItemID 146,146,1
|
||||
*/
|
||||
create PROCEDURE [dbo].[getContentAuditsChronologyPastByItemID]
|
||||
(
|
||||
@ProcedureItemID int,
|
||||
@SelectedItemID int,
|
||||
@IncludeDeletedChildren int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
order by OrdinalPath, contentid,auditid--actionwhen
|
||||
RETURN
|
||||
end
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getContentAuditsSummaryPastByItemID] Script Date: 11/01/2011 18:17:56 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getContentAuditsSummaryPastByItemID] ******/
|
||||
/*
|
||||
getContentAuditsSummaryPastByItemID 146,146,0
|
||||
getContentAuditsSummaryPastByItemID 41,41,0
|
||||
getContentAuditsSummaryPastByItemID 9,9,0
|
||||
getContentAuditsSummaryPastByItemID 146,146,1
|
||||
*/
|
||||
create PROCEDURE [dbo].[getContentAuditsSummaryPastByItemID]
|
||||
(
|
||||
@ProcedureItemID int,
|
||||
@SelectedItemID int,
|
||||
@IncludeDeletedChildren int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
|
||||
select z.* from
|
||||
(
|
||||
select contentid,min(auditid) auditid from
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) x
|
||||
group by contentid
|
||||
) y
|
||||
inner join
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID,ordinalpath
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) z on y.contentid = z.contentid and y.auditid = z.auditid
|
||||
union
|
||||
select z.* from
|
||||
(
|
||||
select contentid,max(auditid) auditid from
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) x
|
||||
group by contentid
|
||||
) y
|
||||
inner join
|
||||
(
|
||||
select [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID,ordinalpath
|
||||
from
|
||||
(
|
||||
select
|
||||
case
|
||||
when lastauditid is null then 'Added'
|
||||
when r.deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = -1 then 'Changed'
|
||||
when DeletedAuditID is not null then 'Restored'
|
||||
-- when DeletedAuditID is not null and lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end actionwhat
|
||||
,actiondts actionwhen
|
||||
-- ,case
|
||||
-- when lastauditid is null then dts
|
||||
-- when r.deletestatus > 0 then ActionDTS
|
||||
-- when lastauditid = -1 then dts
|
||||
-- when DeletedAuditID is not null then ActionDTS
|
||||
-- else dts
|
||||
-- end actionwhen
|
||||
,*
|
||||
from vefn_tblchilditems (@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) t
|
||||
inner join vefn_chronologyreportpast(@ProcedureItemID) r
|
||||
on t.icontentid = r.contentid
|
||||
-- where ActionDTS > procdts or dts > procdts
|
||||
) ah
|
||||
) z on y.contentid = z.contentid and y.auditid = z.auditid
|
||||
order by OrdinalPath, contentid,auditid--actionwhen
|
||||
RETURN
|
||||
end
|
||||
go
|
2509
PROMS/SQL/6_Approval_Support_Procs_Funcs.sql
Normal file
2509
PROMS/SQL/6_Approval_Support_Procs_Funcs.sql
Normal file
File diff suppressed because it is too large
Load Diff
2397
PROMS/SQL/6_Approval_Support_Procs_Funcs.sql.bak
Normal file
2397
PROMS/SQL/6_Approval_Support_Procs_Funcs.sql.bak
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
select 'select ''' + name + ''' dbname, count(*) howmany from ' + name + '.dbo.contents cp
|
||||
join ' + name + '.dbo.parts pp on pp.contentid = cp.contentid
|
||||
join ' + name + '.dbo.items ii on pp.itemid = ii.itemid
|
||||
join ' + name + '.dbo.contents cc on cc.contentid = ii.contentid
|
||||
where cp.type = 20014 and cc.type = 20014 union' from sys.databases where name like '%WCN%'
|
||||
|
2
PROMS/SQL/Across Databases/Types.sql
Normal file
2
PROMS/SQL/Across Databases/Types.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
select 'select ''' + name + ''' dbname, count(*) howmany from ' + name + '.dbo.contents
|
||||
where type = 20014 union' from sys.databases where name like '%WCN%'
|
18
PROMS/SQL/Across Databases/querymultibledatabases.sql
Normal file
18
PROMS/SQL/Across Databases/querymultibledatabases.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
declare @dbNames nvarchar(max)
|
||||
set @dbnames = 'VEPROMS_%'
|
||||
declare @CommandLine nvarchar(max)
|
||||
set quoted_identifier off -- Allows single quotes to be used in the query'
|
||||
set @CommandLine = "
|
||||
Select
|
||||
sum(case when type = 0 then 1 else 0 end) Procedures
|
||||
,sum(case when type between 10000 and 19999 then 1 else 0 end) Sections
|
||||
,sum(case when type >= 20000 then 1 else 0 end) Steps
|
||||
from ~Contents
|
||||
"
|
||||
set quoted_identifier on
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + 'select ''' + Name + ''' DBName, * from ( ' + Replace(Replace(@CommandLine,'~','{Name}.dbo.'),'{Name}',Name) + ') T1'
|
||||
from Sys.Databases where name like @dbNames and name not like '%test'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t2 '--where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
32
PROMS/SQL/AddDROUsages.sql
Normal file
32
PROMS/SQL/AddDROUsages.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
/****** Object: Table [dbo].[DROUsages] Script Date: 01/19/2011 13:22:18 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[DROUsages](
|
||||
[DROUsageID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[DocID] [int] NOT NULL CONSTRAINT [DF_Table_1_ContentID] DEFAULT ((0)),
|
||||
[ROID] [nvarchar](16) NOT NULL,
|
||||
[Config] [nvarchar](max) NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_DROUsages_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_DROUsages_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
[RODbID] [int] NOT NULL,
|
||||
CONSTRAINT [PK_DROUsages] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[DROUsageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DROUsages', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
ALTER TABLE [dbo].[DROUsages] WITH CHECK ADD CONSTRAINT [FK_DROUsages_Documents] FOREIGN KEY([DocID])
|
||||
REFERENCES [dbo].[Documents] ([DocID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[DROUsages] CHECK CONSTRAINT [FK_DROUsages_Documents]
|
||||
GO
|
||||
ALTER TABLE [dbo].[DROUsages] WITH CHECK ADD CONSTRAINT [FK_DROUsages_RODbs] FOREIGN KEY([RODbID])
|
||||
REFERENCES [dbo].[RODbs] ([RODbID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[DROUsages] CHECK CONSTRAINT [FK_DROUsages_RODbs]
|
58
PROMS/SQL/AddGridsAndImages.sql
Normal file
58
PROMS/SQL/AddGridsAndImages.sql
Normal file
@@ -0,0 +1,58 @@
|
||||
/****** Object: Table [dbo].[Grids] Script Date: 01/18/2011 14:30:21 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Grids](
|
||||
[ContentID] [int] NOT NULL,
|
||||
[Data] [xml] NOT NULL,
|
||||
[Config] [xml] NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Grids_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Grids_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Grids] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ContentID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Grids', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
ALTER TABLE [dbo].[Grids] WITH CHECK ADD CONSTRAINT [FK_Grids_Contents] FOREIGN KEY([ContentID])
|
||||
REFERENCES [dbo].[Contents] ([ContentID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Grids] CHECK CONSTRAINT [FK_Grids_Contents]
|
||||
/****** Object: Table [dbo].[Images] Script Date: 01/18/2011 14:32:12 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Images](
|
||||
[ContentID] [int] NOT NULL,
|
||||
[ImageType] [int] NOT NULL CONSTRAINT [DF_Images_ImageType] DEFAULT ((1)),
|
||||
[FileName] [nvarchar](255) NOT NULL,
|
||||
[Data] [varbinary](max) NOT NULL,
|
||||
[Config] [xml] NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Images_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Images_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Images] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ContentID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
SET ANSI_PADDING OFF
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1 - Figure, 2 - Video, 3 - Audio' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Images', @level2type=N'COLUMN',@level2name=N'ImageType'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Images', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
ALTER TABLE [dbo].[Images] WITH CHECK ADD CONSTRAINT [FK_Images_Contents] FOREIGN KEY([ContentID])
|
||||
REFERENCES [dbo].[Contents] ([ContentID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Images] CHECK CONSTRAINT [FK_Images_Contents]
|
42
PROMS/SQL/AllDBsMultipleIndents.sql
Normal file
42
PROMS/SQL/AllDBsMultipleIndents.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select ''{Name}'' dbname, ' +
|
||||
' len(text+''x'')-len(replace(text,nchar(5),'''')+''x'') indents,' +
|
||||
' len(text+''x'')-len(replace(text,nchar(13),'''')+''x'') crs,' +
|
||||
' len(text+''x'')-len(replace(text,nchar(10),'''')+''x'') nls,' +
|
||||
' (len(text+''x'')-len(replace(text,''\par'','''')+''x''))/4 pars,' +
|
||||
' (len(text+''x'')-len(replace(text,''\line'','''')+''x''))/5 lines,' +
|
||||
' case when' +
|
||||
' (case when charindex(''\line'',text) > charindex(nchar(13),text) ' +
|
||||
' then charindex(''\line'',text) else charindex(nchar(13),text) end)' +
|
||||
' -charindex(nchar(5),text) > 0 then ''FirstLine'' else ''OtherLine'' end location, ' +
|
||||
' count(*) howmany, ' + --cc.contentid, type, text,
|
||||
'case when gg.contentid is null then ''not grid'' else ''grid'' end isgrid' +
|
||||
' from {Name}.dbo.contents cc left join {Name}.dbo.grids gg on gg.contentid = cc.contentid' +
|
||||
' where text like ''%'' +nchar(5) + ''%'' ' +
|
||||
'group by case when gg.contentid is null then ''not grid'' else ''grid'' end, '+
|
||||
'len(text+''x'')-len(replace(text,nchar(5),'''')+''x''),' +
|
||||
'len(text+''x'')-len(replace(text,nchar(13),'''')+''x''),' +
|
||||
'len(text+''x'')-len(replace(text,nchar(10),'''')+''x''),' +
|
||||
'len(text+''x'')-len(replace(text,''\par'','''')+''x''),' +
|
||||
'len(text+''x'')-len(replace(text,''\line'','''')+''x''),' +
|
||||
'case when' +
|
||||
' (case when charindex(''\line'',text) > charindex(nchar(13),text) ' +
|
||||
' then charindex(''\line'',text) else charindex(nchar(13),text) end)' +
|
||||
' -charindex(nchar(5),text) > 0 then ''FirstLine'' else ''OtherLine'' end '
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(@CommandLine,'{Name}',Name)
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1 where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
||||
|
||||
select contentid, substring(text, 1, 20) found, len(text) textlen from veproms_FNP.dbo.contents
|
||||
where text like '%' + nchar(5) + '%'
|
||||
|
||||
|
||||
select text, cc.contentid, len(text) length, len(text+'x')-len(replace(text,nchar(5),'')+'x') indents,
|
||||
case when gg.contentid is null then 'not grid' else 'grid' end isgrid
|
||||
, unicode(substring(text,10,1)) uni
|
||||
from VEPROMS_APP.dbo.contents cc left join VEPROMS_APP.dbo.grids gg on gg.contentid = cc.contentid
|
||||
where text like '%' +nchar(5) + '%' and
|
||||
len(text+'x')-len(replace(text,nchar(5),'')+'x') > 1
|
31
PROMS/SQL/AllDBsMultipleIndentsDetails.sql
Normal file
31
PROMS/SQL/AllDBsMultipleIndentsDetails.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select ''{Name}'' dbname, cc.contentid, ' +
|
||||
' len(text+''x'')-len(replace(text,nchar(5),'''')+''x'') indents,' +
|
||||
' len(text+''x'')-len(replace(text,nchar(13),'''')+''x'') crs,' +
|
||||
' len(text+''x'')-len(replace(text,nchar(10),'''')+''x'') nls,' +
|
||||
' (len(text+''x'')-len(replace(text,''\par'','''')+''x''))/4 pars,' +
|
||||
' (len(text+''x'')-len(replace(text,''\line'','''')+''x''))/5 lines,' +
|
||||
' case when' +
|
||||
' (case when charindex(''\line'',text) > charindex(nchar(13),text) ' +
|
||||
' then charindex(''\line'',text) else charindex(nchar(13),text) end)' +
|
||||
' -charindex(nchar(5),text) > 0 then ''FirstLine'' else ''OtherLine'' end location, ' +
|
||||
'case when gg.contentid is null then ''not grid'' else ''grid'' end isgrid' +
|
||||
' from {Name}.dbo.contents cc left join {Name}.dbo.grids gg on gg.contentid = cc.contentid' +
|
||||
' where text like ''%'' +nchar(5) + ''%'' '
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(@CommandLine,'{Name}',Name)
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
||||
|
||||
select contentid, substring(text, 1, 20) found, len(text) textlen from veproms_FNP.dbo.contents
|
||||
where text like '%' + nchar(5) + '%'
|
||||
|
||||
|
||||
select text, cc.contentid, len(text) length, len(text+'x')-len(replace(text,nchar(5),'')+'x') indents,
|
||||
case when gg.contentid is null then 'not grid' else 'grid' end isgrid
|
||||
, unicode(substring(text,10,1)) uni
|
||||
from VEPROMS_APP.dbo.contents cc left join VEPROMS_APP.dbo.grids gg on gg.contentid = cc.contentid
|
||||
where text like '%' +nchar(5) + '%' and
|
||||
len(text+'x')-len(replace(text,nchar(5),'')+'x') > 1
|
31
PROMS/SQL/AllDBsMultipleIndentsThenDetails.sql
Normal file
31
PROMS/SQL/AllDBsMultipleIndentsThenDetails.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select ''{Name}'' dbname, cc.contentid, ' +
|
||||
' len(text+''x'')-len(replace(text,nchar(5),'''')+''x'') indents,' +
|
||||
' len(text+''x'')-len(replace(text,nchar(13),'''')+''x'') crs,' +
|
||||
' len(text+''x'')-len(replace(text,nchar(10),'''')+''x'') nls,' +
|
||||
' (len(text+''x'')-len(replace(text,''\par'','''')+''x''))/4 pars,' +
|
||||
' (len(text+''x'')-len(replace(text,''\line'','''')+''x''))/5 lines,' +
|
||||
' case when' +
|
||||
' (case when charindex(''\line'',text) > charindex(nchar(13),text) ' +
|
||||
' then charindex(''\line'',text) else charindex(nchar(13),text) end)' +
|
||||
' -charindex(nchar(5),text) > 0 then ''FirstLine'' else ''OtherLine'' end location, ' +
|
||||
'case when gg.contentid is null then ''not grid'' else ''grid'' end isgrid' +
|
||||
' from {Name}.dbo.contents cc left join {Name}.dbo.grids gg on gg.contentid = cc.contentid' +
|
||||
' where text like ''%'' +nchar(5) + ''%THEN%'' '
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(@CommandLine,'{Name}',Name)
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
||||
|
||||
select contentid, substring(text, 1, 20) found, len(text) textlen from veproms_FNP.dbo.contents
|
||||
where text like '%' + nchar(5) + '%'
|
||||
|
||||
|
||||
select text, cc.contentid, len(text) length, len(text+'x')-len(replace(text,nchar(5),'')+'x') indents,
|
||||
case when gg.contentid is null then 'not grid' else 'grid' end isgrid
|
||||
, unicode(substring(text,10,1)) uni
|
||||
from VEPROMS_APP.dbo.contents cc left join VEPROMS_APP.dbo.grids gg on gg.contentid = cc.contentid
|
||||
where text like '%' +nchar(5) + '%' and
|
||||
len(text+'x')-len(replace(text,nchar(5),'')+'x') > 1
|
18
PROMS/SQL/AllDatabaseFindIndent.sql
Normal file
18
PROMS/SQL/AllDatabaseFindIndent.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select ''{Name}'' dbname, ' +
|
||||
' len(text)-len(replace(text,nchar(5),'''')) indents,' +
|
||||
' count(*) howmany, ' + --cc.contentid, type, text,
|
||||
'case when gg.contentid is null then ''not grid'' else ''grid'' end isgrid' +
|
||||
' from {Name}.dbo.contents cc left join {Name}.dbo.grids gg on gg.contentid = cc.contentid' +
|
||||
' where text like ''%'' +nchar(5) + ''%'' ' +
|
||||
'group by case when gg.contentid is null then ''not grid'' else ''grid'' end, '+
|
||||
'len(text)-len(replace(text,nchar(5),''''))'
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(@CommandLine,'{Name}',Name)
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1 where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
||||
|
||||
select contentid, substring(text, 1, 20) found, len(text) textlen from veproms_FNP.dbo.contents
|
||||
where text like '%' + nchar(5) + '%'
|
14
PROMS/SQL/AllDatabaseFindIndentTHEN.sql
Normal file
14
PROMS/SQL/AllDatabaseFindIndentTHEN.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select ''{Name}'' dbname, count(*) howmany, ' + --cc.contentid, type, text,
|
||||
'case when gg.contentid is null then ''not grid'' else ''grid'' end isgrid' +
|
||||
' from {Name}.dbo.contents cc left join {Name}.dbo.grids gg on gg.contentid = cc.contentid' +
|
||||
' where text like ''%'' +nchar(5) + ''% THEN %'' COLLATE Latin1_General_CS_AS ' +
|
||||
'group by case when gg.contentid is null then ''not grid'' else ''grid'' end'
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(@CommandLine,'{Name}',Name)
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1 where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
||||
|
||||
select contentid, substring(text, charindex('THEN', text)-5, 15) found from veproms_BGE_STP.dbo.contents where text like '%' + nchar(5) + '% THEN %' COLLATE Latin1_General_CS_AS
|
11
PROMS/SQL/AllDatabaseFindRtfLine.sql
Normal file
11
PROMS/SQL/AllDatabaseFindRtfLine.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select ''{Name}'' dbname, count(*) howmany, ' + --cc.contentid, type, text,
|
||||
'case when gg.contentid is null then ''not grid'' else ''grid'' end isgrid' +
|
||||
' from {Name}.dbo.contents cc left join {Name}.dbo.grids gg on gg.contentid = cc.contentid where text like ''%\line%'' ' +
|
||||
'group by case when gg.contentid is null then ''not grid'' else ''grid'' end'
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(@CommandLine,'{Name}',Name)
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1 where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
12
PROMS/SQL/AllDatabases_FindROsInMergedTableCells.sql
Normal file
12
PROMS/SQL/AllDatabases_FindROsInMergedTableCells.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select distinct ru.contentid, "{Name}" dbname,
|
||||
case when cast(data as nvarchar(max)) like "%mergedranges%" then "true" else "false" end merged from ~Grids GG
|
||||
Join ~ROUsages RU ON RU.ContentID =GG.ContentID
|
||||
where cast(data as nvarchar(max)) like "%:" + cast(rousageid as varchar(10)) + "%:" + cast(rousageid as varchar(10)) + "%"
|
||||
'
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(Replace(Replace(@CommandLine,'~','{Name}.dbo.'),'{Name}',Name),'"','''')
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1 '--where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
6
PROMS/SQL/BGEConfigPrintHdr.sql
Normal file
6
PROMS/SQL/BGEConfigPrintHdr.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
select contentid, printHdr, type, dbo.ve_getshortpathfromcontentid(contentid) from (
|
||||
select contentid, Number, Type, isnull(xSection.value('@PrintHdr', 'varchar(255)'),'Y') printHdr from (
|
||||
select cast(config as xml) xconfig, * from contents where type between 10000 and 19999
|
||||
and contentid in (select contentid from parts where fromtype = 2) --and contentid in (12859, 12995)
|
||||
) sectp
|
||||
outer apply xconfig.nodes('//Section') tSection(xSection)) kr where printHdr='N'
|
7
PROMS/SQL/BGEOIAlarmSectionUsage.sql
Normal file
7
PROMS/SQL/BGEOIAlarmSectionUsage.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
select vi.versionid, vn.foldername, vi.formatid, itemid, .dbo.ve_getshortpath(itemid) location
|
||||
from vefn_getversionformatitems('') vi
|
||||
join vefn_getversionnames() vn on vn.versionid = vi.versionid
|
||||
join contents cc on cc.contentid = vi.contentid
|
||||
where cc.type between 10000 and 19999
|
||||
and vi.formatid = 13
|
||||
order by itemid
|
7
PROMS/SQL/BGEOIAlarmSectionUsageSummary.sql
Normal file
7
PROMS/SQL/BGEOIAlarmSectionUsageSummary.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
select vi.versionid, vn.foldername, vi.formatid, count(*) howmany -- itemid, .dbo.ve_getshortpath(itemid) location
|
||||
from vefn_getversionformatitems('') vi
|
||||
join vefn_getversionnames() vn on vn.versionid = vi.versionid
|
||||
join contents cc on cc.contentid = vi.contentid
|
||||
where cc.type between 10000 and 19999
|
||||
--and vi.formatid = 13
|
||||
group by vi.versionid, vn.foldername, vi.formatid
|
6
PROMS/SQL/BGETitleWithTextSiblings.sql
Normal file
6
PROMS/SQL/BGETitleWithTextSiblings.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
select CC.Text, count(*) HowMany
|
||||
from Contents CC
|
||||
Join Parts PP ON CC.ContentID = PP.ContentID
|
||||
Join Items IP ON IP.PreviousID = pp.ItemID
|
||||
where type = 20042
|
||||
Group By cc.TEXT
|
6
PROMS/SQL/BGETitleWithTextSiblingsCount.sql
Normal file
6
PROMS/SQL/BGETitleWithTextSiblingsCount.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
select Text, SiblingAndChildren, Count(*) HowMany
|
||||
from ( select CC.Text, (select count(*) from vefn_SiblingChildrenItems(PP.ItemID)) SiblingAndChildren
|
||||
from Contents CC
|
||||
Join Parts PP ON CC.ContentID = PP.ContentID
|
||||
where type = 20042) T1
|
||||
Group By Text,SiblingAndChildren
|
11
PROMS/SQL/BGETitleWithTextSiblingsDetails.sql
Normal file
11
PROMS/SQL/BGETitleWithTextSiblingsDetails.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
select VN.FolderName, dbo.ve_GetShortPathFromContentID(T1.ContentID) Path, T1.ContentID
|
||||
from vefn_GetVersionNames() VN
|
||||
Join vefn_GetVersionItems('') VI ON VI.VersionID = VN.VersionID
|
||||
Join
|
||||
(
|
||||
select CC.CONTENTID
|
||||
from Contents CC
|
||||
Join Parts PP ON CC.ContentID = PP.ContentID
|
||||
Join Items IP ON IP.PreviousID = pp.ItemID
|
||||
where type = 20042
|
||||
) T1 ON T1.ContentId = VI.Contentid
|
6
PROMS/SQL/BGEVLV.sql
Normal file
6
PROMS/SQL/BGEVLV.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
select text, count(*) howmany from
|
||||
(select vn.foldername, itemid, dbo.ve_getshortpath(itemid) location, text, vi.formatid from contents cc
|
||||
join vefn_getversionformatitems('') vi on vi.contentid = cc.contentid
|
||||
join vefn_getversionnames() vn on vn.versionid = vi.versionid
|
||||
where type = 20007 and vi.formatid = 16) ftnt
|
||||
group by text
|
19
PROMS/SQL/BugDeltaSQL.TXT
Normal file
19
PROMS/SQL/BugDeltaSQL.TXT
Normal file
@@ -0,0 +1,19 @@
|
||||
select vv.* , cc.Text
|
||||
from vefn_GetVersionFormatItems('136,137,138,139') vv
|
||||
join Contents CC on CC.ContentID = VV.ContentID
|
||||
where text like '%u916[a-zA-Z]%'
|
||||
--join docversions dv on vv.versionid = dv.versionid
|
||||
--Join folders ff on ff.FolderID = DV.FolderID
|
||||
--Join folders pf on pf.FolderID = ff.parentID
|
||||
--Join folders gf on gf.FolderID = pf.parentid
|
||||
--join formats fm on fm.formatid = vv.formatid
|
||||
|
||||
|
||||
select vv.versionid, ff.name folder, pf.name parent, gf.name grandparent, vv.formatid, fm.name, count(*) HowMany
|
||||
from vefn_GetVersionFormatItems('') vv
|
||||
join docversions dv on vv.versionid = dv.versionid
|
||||
Join folders ff on ff.FolderID = DV.FolderID
|
||||
Join folders pf on pf.FolderID = ff.parentID
|
||||
Join folders gf on gf.FolderID = pf.parentid
|
||||
join formats fm on fm.formatid = vv.formatid
|
||||
group by vv.versionid, ff.name, pf.name, gf.name, vv.formatid, fm.name
|
1
PROMS/SQL/ChangeDBOwner.sql
Normal file
1
PROMS/SQL/ChangeDBOwner.sql
Normal file
@@ -0,0 +1 @@
|
||||
sp_changedbowner sa
|
3
PROMS/SQL/ChangeXMLfield.sql
Normal file
3
PROMS/SQL/ChangeXMLfield.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
update Formats
|
||||
set Data = Cast(Replace(Cast(Data as nvarchar(max)),'\xA033 13','SECTION') as XML)
|
||||
where Name = 'RGESAM1'
|
9
PROMS/SQL/Consistency1.sql
Normal file
9
PROMS/SQL/Consistency1.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
select ItemID,replace(Number,'\u8209?','-') ProcNum
|
||||
, (Select count(*) Howmany from vefn_FindExternalChildTransitions(ItemID)) ExternalTransitions
|
||||
, (select count(*) from (select distinct roid from vefn_ChildItems(ItemID) cc join rousages rr on cc.contentid = rr.contentid)t1) UniqueROs
|
||||
, (select count(*) from (select distinct dd.docid,libtitle from vefn_ChildItems(ItemID) cc join entries ee on cc.contentid = ee.contentid
|
||||
join documents dd on dd.docid=ee.docid where libtitle <> '')t1) UniqueLibDocs
|
||||
from Items II
|
||||
join Contents CC on II.ContentID = CC.ContentID
|
||||
where Type < 10000
|
||||
|
BIN
PROMS/SQL/CopyStepTest.sql
Normal file
BIN
PROMS/SQL/CopyStepTest.sql
Normal file
Binary file not shown.
38
PROMS/SQL/CreatePDFTable.sql
Normal file
38
PROMS/SQL/CreatePDFTable.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
ALTER TABLE Documents DROP COLUMN DocPdf
|
||||
|
||||
CREATE TABLE [dbo].[Pdfs](
|
||||
[DocID] [int] NOT NULL,
|
||||
[DebugStatus] [int] NOT NULL,
|
||||
[TopRow] [int] NOT NULL,
|
||||
[PageLength] [int] NOT NULL,
|
||||
[LeftMargin] [int] NOT NULL,
|
||||
[PageWidth] [int] NOT NULL,
|
||||
[PageCount] [float] NOT NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Pdfs_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Pdfs_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
[DocPdf] [varbinary](max) NULL,
|
||||
|
||||
CONSTRAINT [PK_Pdfs] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[DocID] ASC,
|
||||
[DebugStatus] ASC,
|
||||
[TopRow] ASC,
|
||||
[PageLength] ASC,
|
||||
[LeftMargin] ASC,
|
||||
[PageWidth] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'> 0 for Debug' , @level0type=N'SCHEMA',@level0name=N'dbo',
|
||||
@level1type=N'TABLE',@level1name=N'Pdfs', @level2type=N'COLUMN',@level2name=N'DebugStatus'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo',
|
||||
@level1type=N'TABLE',@level1name=N'Pdfs', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
|
||||
GO
|
||||
ALTER TABLE [dbo].[Pdfs] WITH CHECK ADD CONSTRAINT [FK_Pdfs_Documents] FOREIGN KEY([DocID])
|
||||
REFERENCES [dbo].[Documents] ([DocID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Pdfs] CHECK CONSTRAINT [FK_Pdfs_Documents]
|
4
PROMS/SQL/DelCATtables.sql
Normal file
4
PROMS/SQL/DelCATtables.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
exec DeleteItemAndChildren 64512, 'MICHELLE'
|
||||
exec DeleteItemAndChildren 64523, 'MICHELLE'
|
||||
exec DeleteItemAndChildren 87580, 'MICHELLE'
|
||||
exec DeleteItemAndChildren 87591, 'MICHELLE'
|
15
PROMS/SQL/DocStyleUsageInFmtsWithValues.sql
Normal file
15
PROMS/SQL/DocStyleUsageInFmtsWithValues.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
select *, case when (pagewidth > (topmargin + pagelength)) then 'true' else 'false' end isLandscape
|
||||
from (select Name formatName,
|
||||
xdocstyle.value('@Name','varchar(255)') docStyle,
|
||||
xdocstyle.value('@IsStepSection','varchar(255)') isStepSection,
|
||||
xlayout.value('@PageWidth', 'real') pageWidth,
|
||||
xlayout.value('@PageLength', 'real') pageLength,
|
||||
xlayout.value('@TopMargin', 'real') topMargin
|
||||
from formats ff
|
||||
cross apply data.nodes('//DocStyle') tdocstyle(xdocstyle)
|
||||
cross apply xdocstyle.nodes('Layout') tlayout(xlayout)
|
||||
where --name like 'WCN%' and
|
||||
xdocstyle.value('@Name','varchar(255)') like '%Landscape%'
|
||||
) hh
|
||||
|
||||
|
16
PROMS/SQL/DocVersionFindSubs.sql
Normal file
16
PROMS/SQL/DocVersionFindSubs.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
--select distinct type from (
|
||||
select vv.versionid, ff.name folder, pf.name parent, gf.name grandparent, fm.formatid, fm.name Format, cc.type
|
||||
,dbo.ve_GetShortPath(vv.ItemID) location
|
||||
--cc.type - 20000 Ind, case when text like '% %' then 'true' else 'false' end HasSpaces, count(*) HowMany
|
||||
from vefn_GetVersionFormatItems('5') vv
|
||||
Join contents cc on cc.ContentID = vv.contentID
|
||||
--join parts pp on pp.ItemID = vv.ItemID
|
||||
join docversions dv on vv.versionid = dv.versionid
|
||||
Join folders ff on ff.FolderID = DV.FolderID
|
||||
Join folders pf on pf.FolderID = ff.parentID
|
||||
Join folders gf on gf.FolderID = pf.parentid
|
||||
join formats fm on fm.formatid = vv.formatid
|
||||
where cc.type in (20006, 20007)
|
||||
--) t1
|
||||
--group by vv.versionid, ff.name, pf.name, gf.name, fm.formatid, fm.name, cc.type
|
||||
--,case when text like '% %' then 'true' else 'false' end
|
5
PROMS/SQL/FMTCheckOff.sql
Normal file
5
PROMS/SQL/FMTCheckOff.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
Select Name, --v.query('.') Query,
|
||||
v.value('@Index','integer') MyIndex,
|
||||
v.value('@RightCheckOffBoxChar','integer') RightCheckOffBoxChar FROM
|
||||
Formats CROSS APPLY Data.nodes('//RightCheckOffBox') TempXML(v)
|
||||
order by v.value('@Index','integer'),Name
|
11
PROMS/SQL/FMTGetAllSeqTab.sql
Normal file
11
PROMS/SQL/FMTGetAllSeqTab.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
SELECT * FROM (
|
||||
Select FormatID, Name
|
||||
, v.value('./@Index', 'int') MyIndex
|
||||
, v.value('./@TabFormat', 'varchar(255)') TabFormat
|
||||
--, v.value('./@PrintTabFormat', 'varchar(255)') PrintTabFormat
|
||||
FROM Formats
|
||||
CROSS APPLY Data.nodes('//SeqTabFmt') TempXML(v)
|
||||
) AS SRC
|
||||
PIVOT( Max(TabFormat) FOR MyIndex IN (
|
||||
[0], [1],[2],[3],[4],[5],[6],[7],[8]
|
||||
)) AS PVT1 Order by FormatID
|
12
PROMS/SQL/FMTGetAllTransTypes.sql
Normal file
12
PROMS/SQL/FMTGetAllTransTypes.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
SELECT * FROM (
|
||||
Select FormatID, Name
|
||||
, v.value('./@TransType', 'int') MyIndex
|
||||
, v.value('./@TransFormat', 'varchar(255)') TabFormat
|
||||
--, v.value('./@PrintTabFormat', 'varchar(255)') PrintTabFormat
|
||||
FROM Formats
|
||||
CROSS APPLY Data.nodes('//TransTypes') TempXML(v)
|
||||
--where v.value('./@TransFormat', 'varchar(255)') like '%{Last Step}%'
|
||||
) AS SRC
|
||||
PIVOT( Max(TabFormat) FOR MyIndex IN (
|
||||
[0], [1],[2],[3],[4],[5],[6],[7],[8], [9], [10], [11]
|
||||
)) AS PVT1 Order by FormatID
|
7
PROMS/SQL/FMTGetSeqTab.sql
Normal file
7
PROMS/SQL/FMTGetSeqTab.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
select * from (
|
||||
Select FormatID, Name, v.query('.') myXML
|
||||
, v.value('./@Index', 'int') MyIndex
|
||||
, v.value('./@TabFormat', 'varchar(255)') TabFormat
|
||||
--, v.value('./@PrintTabFormat', 'varchar(255)') PrintTabFormat
|
||||
FROM Formats
|
||||
CROSS APPLY Data.nodes('//SeqTabFmt') TempXML(v) ) t1 where TabFormat like '%+%'
|
15
PROMS/SQL/FMTLandscapeBug.sql
Normal file
15
PROMS/SQL/FMTLandscapeBug.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
--select * from formats
|
||||
select * from (
|
||||
SELECT FormatID,Name,ParentID
|
||||
--,XDocStyle.query('.') NodeDocStyle
|
||||
--,XLayout.query('.') NodeLayout
|
||||
,XDocStyle.value('@Index', 'int') AS [MyIndex]
|
||||
,XDocStyle.value('@Name', 'nvarchar(100)') AS [MyDSName]
|
||||
,XDocStyle.value('@IsStepSection', 'nvarchar(5)') AS [MyIsStepSect]
|
||||
,XLayout.value('@TopMargin', 'real') AS [MyTopMargin]
|
||||
,XLayout.value('@PageLength', 'real') AS [MyPageLength]
|
||||
,XLayout.value('@PageWidth', 'real') AS [MyPageWidth]
|
||||
From Formats
|
||||
CROSS APPLY Data.nodes('//DocStyle') TempXML(XDocStyle)
|
||||
CROSS APPLY XDocStyle.nodes('Layout') TempXML1(XLayout)) LandScapeBug
|
||||
where MyPageWidth > MyPageLength and MyIsStepSect = 'false'
|
4
PROMS/SQL/FMTXML.SQL
Normal file
4
PROMS/SQL/FMTXML.SQL
Normal file
@@ -0,0 +1,4 @@
|
||||
SELECT FormatID,Name,ParentID
|
||||
,v.query('.') NodeItself
|
||||
,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats
|
||||
CROSS APPLY Data.nodes('//CheckOffHeader') TempXML(v)
|
2
PROMS/SQL/FMTXMLFindString.sql
Normal file
2
PROMS/SQL/FMTXMLFindString.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
select * from formats where Cast(Data as nvarchar(max)) like '%\xA033%'
|
||||
|
5
PROMS/SQL/FMTXMLGetSeperator.sql
Normal file
5
PROMS/SQL/FMTXMLGetSeperator.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
Select distinct
|
||||
v.value('./@Sep', 'varchar(255)') Sep
|
||||
FROM Formats
|
||||
CROSS APPLY Data.nodes('//*[@Sep]') TempXML(v)
|
||||
where v.value('./@Sep', 'varchar(255)') like '%\%'
|
10
PROMS/SQL/FMT_PAGE_OfToken.sql
Normal file
10
PROMS/SQL/FMT_PAGE_OfToken.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
SELECT FormatID, Name, Description
|
||||
,v.query('.') FontNode
|
||||
,v.query('..') ParentNode
|
||||
,v.value('@Token', 'varchar(100)') AS TokenText
|
||||
,v.value('@Justify', 'varchar(100)') AS Justify
|
||||
FROM Formats
|
||||
CROSS APPLY Data.nodes('//Item') TempXML(v)
|
||||
|
||||
where v.value('@Token', 'varchar(100)') like '%{PAGE}%'
|
||||
|
3010
PROMS/SQL/Final_Approval_Script.sql
Normal file
3010
PROMS/SQL/Final_Approval_Script.sql
Normal file
File diff suppressed because it is too large
Load Diff
3007
PROMS/SQL/Final_Approval_Script.sql.bak
Normal file
3007
PROMS/SQL/Final_Approval_Script.sql.bak
Normal file
File diff suppressed because it is too large
Load Diff
6
PROMS/SQL/FindAERTables.sql
Normal file
6
PROMS/SQL/FindAERTables.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
select dv.versionid, ff.name, .dbo.ve_getshortpathfromcontentid(cc.contentid) location
|
||||
from contents cc
|
||||
join vefn_getversionitems('') vv on vv.contentid = cc.contentid
|
||||
join docversions dv on dv.versionid = vv.versionid
|
||||
join folders ff on ff.folderid = dv.folderid
|
||||
where type = 20010
|
14
PROMS/SQL/FindAllHSPinROFST.sql
Normal file
14
PROMS/SQL/FindAllHSPinROFST.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
declare @dbNames nvarchar(max)
|
||||
set @dbnames = 'VEPROMS_%'
|
||||
declare @CommandLine nvarchar(max)
|
||||
set quoted_identifier off -- Allows single quotes to be used in the query'
|
||||
set @CommandLine = "
|
||||
select Count(*) HowMany from ~rofsts where rolookup like '%@HSP(%'
|
||||
"
|
||||
set quoted_identifier on
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + 'select ''' + Name + ''' DBName, * from ( ' + Replace(Replace(@CommandLine,'~','{Name}.dbo.'),'{Name}',Name) + ') T1'
|
||||
from Sys.Databases where name like @dbNames and name not like '%test'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t2 '--where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
7
PROMS/SQL/FindFMTUses.sql
Normal file
7
PROMS/SQL/FindFMTUses.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
select VI.VersionID, VN.ParentName, VN.FolderName,FF.FormatID, FF.Name, .dbo.ve_getshortPath(vi.ItemID) Location
|
||||
from vefn_GetVersionFormatItems('') VI
|
||||
Join Formats FF on FF.FormatID = VI.FormatID
|
||||
Join vefn_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
Join Contents CC on VI.ContentID = Cc.ContentID
|
||||
Where CC.Type < 20000 and FF.Name = 'GEN'
|
||||
order by VersionID, Location
|
3
PROMS/SQL/FindROTables.sql
Normal file
3
PROMS/SQL/FindROTables.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select * from grids gg
|
||||
Join Contents CC ON GG.ContentID = CC.ContentID where cc.contentid in (select contentID from rousages)
|
||||
And cast(Data as varchar(max)) like '%<IsRoTable>True</IsRoTable>%'
|
6
PROMS/SQL/FindROlinkCharB4.sql
Normal file
6
PROMS/SQL/FindROlinkCharB4.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
--select * from vefn_getversionnames()
|
||||
select *, substring(text, charindex('<START]', text)-5, 20) strt
|
||||
from vefn_getversionitems('13,14,15,16') vi
|
||||
join contents cc on cc.contentid = vi.contentid
|
||||
join rousages ru on ru.contentid = cc.contentid
|
||||
where versionid in (13, 14, 15, 16)
|
172
PROMS/SQL/FindSample.sql
Normal file
172
PROMS/SQL/FindSample.sql
Normal file
@@ -0,0 +1,172 @@
|
||||
USE VEPROMS
|
||||
/* -- Children have Transitions
|
||||
select * from vefn_AllHighLevelStepTransitions() where ExternalChildTransitions > 0 ;
|
||||
-- 6991 `0POP05-EO-EC32`PROCEDURE STEPS`17 ExternalChildTrans = 1 `0POP05-EO-EC32`PROCEDURE STEPS`14`2`RNO``2
|
||||
-->9392 `0POP05-EO-FRP1`PROCEDURE STEPS`18 ExternalChildTrans = 2 `0POP05-EO-FRP1`PROCEDURE STEPS`25`RNO``1 `0POP05-EO-FRP1`PROCEDURE STEPS`25`RNO``4
|
||||
/* -- External Transitions to step and no nextstep
|
||||
select II.ItemID,dbo.ve_GetShortPath(II.ItemID) Path, dbo.ve_GetChildCount(II.ItemID) ChildCount
|
||||
, (Select count(*) from vefn_FindExternalTransitions(II.ItemID)) ExternalTransCount
|
||||
from Items II join Transitions TT on II.ContentID = TT.FromID
|
||||
left join Items PP on II.ItemID = PP.PreviousID
|
||||
where PP.ItemID is null AND dbo.ve_GetChildCount(II.ItemID) > 1
|
||||
AND (Select count(*) from vefn_FindExternalTransitions(II.ItemID)) > 0
|
||||
-->4984 `0POP05-EO-EC01`PROCEDURE STEPS`14`2 ExternalTrans = 1 `0POP05-EO-EC01`PROCEDURE STEPS`14`1`RNO``1
|
||||
-- 2025 `0POP05-EO-ES11`PROCEDURE STEPS`12`2 ExternalTrans = 1 `0POP05-EO-ES11`PROCEDURE STEPS`12`1`RNO``1
|
||||
-- 3308 `0POP05-EO-EO30`PROCEDURE STEPS`28`2 ExternalTrans = 1 `0POP05-EO-EO30`PROCEDURE STEPS`28`1`RNO``1
|
||||
-- 6116 `0POP05-EO-EC21`PROCEDURE STEPS`24`2 ExternalTrans = 1 `0POP05-EO-EC21`PROCEDURE STEPS`24`1`RNO``1
|
||||
*/
|
||||
/* -- Update next item <20> Step with next item
|
||||
select II.ItemID,dbo.ve_GetShortPath(II.ItemID) Path,dbo.ve_GetShortPath(PP.ItemID) NextPath, dbo.ve_GetChildCount(II.ItemID) ChildCount
|
||||
, (Select count(*) from vefn_FindExternalTransitions(II.ItemID)) ExternalTransCount
|
||||
from Items II join Transitions TT on II.ContentID = TT.FromID
|
||||
left join Items PP on II.ItemID = PP.PreviousID
|
||||
where PP.ItemID is not null AND dbo.ve_GetChildCount(II.ItemID) > 1
|
||||
AND (Select count(*) from vefn_FindExternalTransitions(II.ItemID)) > 0
|
||||
-- 1406 `0POP05-EO-ES05`PROCEDURE STEPS`25`4 Next `0POP05-EO-ES05`PROCEDURE STEPS`25`5 ChildCount=2 ExternalTrans=2
|
||||
-- 2350 `0POP05-EO-ES12`PROCEDURE STEPS`12 Next `0POP05-EO-ES12`PROCEDURE STEPS`13 ChildCount=2 ExternalTrans=2
|
||||
-- 3079 `0POP05-EO-EO30`PROCEDURE STEPS`7`9 Next `0POP05-EO-EO30`PROCEDURE STEPS`7`10 ChildCount=4 ExternalTrans=1
|
||||
-->5167 `0POP05-EO-EC02`PROCEDURE STEPS`12 Next `0POP05-EO-EC02`PROCEDURE STEPS`13 ChildCount=3 ExternalTrans=2
|
||||
-- 8563 `0POP05-EO-FRH1`PROCEDURE STEPS`7 Next `0POP05-EO-FRH1`PROCEDURE STEPS`8 ChildCount=2 ExternalTrans=2
|
||||
-- 8614 `0POP05-EO-FRH1`PROCEDURE STEPS`14 Next `0POP05-EO-FRH1`PROCEDURE STEPS`15 ChildCount=2 ExternalTrans=1
|
||||
-- 9541 `0POP05-EO-FRZ1`PROCEDURE STEPS`2 Next `0POP05-EO-FRZ1`PROCEDURE STEPS`3 ChildCount=2 ExternalTrans=2*/
|
||||
/* -- Update DocVersion ItemID <20> First Procedure in set
|
||||
select ItemID,dbo.ve_GetFolderPath(VersionID) FolderPath from DocVersions where ItemID is not null
|
||||
-->1 Active Plant DataSTPNOC - South TexasEmergency ProceduresWorking Draft
|
||||
-- 51 Active Plant DataSTPNOC - South TexasTest Approval with TransitionsTest Approval with Transitions
|
||||
*/
|
||||
/* -- Update Parts <20> First Section / Step / Sub-step
|
||||
select * from (
|
||||
select PP.ItemID,dbo.ve_GetShortPath(PP.ItemID) Path,dbo.ve_GetSiblingCount(PP.ItemID) Siblings , PP.FromType, CC.Type,
|
||||
row_number()over(partition by FromType order by dbo.ve_GetSiblingCount(PP.ItemID) desc) RowNumber
|
||||
from Parts PP
|
||||
join Items II on PP.ItemID = II.ItemID
|
||||
join Contents CC on CC.ContentID = II.ContentID
|
||||
) t1
|
||||
where RowNumber < 3
|
||||
order by FromType,RowNumber
|
||||
-- ItemID Path Siblings FromType Type RowNumber
|
||||
-- 2969 `0POP05-EO-EO30`COVER 18 2 10001 1
|
||||
-- 1145 `0POP05-EO-ES05`COVER 16 2 10001 2
|
||||
-- 7682 `0POP05-EO-FRS1`PROCEDURE STEPS`15`Caution`1 3 3 20006 1
|
||||
-- 7416 `0POP05-EO-EC33`PROCEDURE STEPS`32`Caution`1 3 3 20006 2
|
||||
-- 4188 `0POP05-EO-EC00`PROCEDURE STEPS`1`Note`1 7 4 20007 1
|
||||
-- 1014 `0POP05-EO-ES03`PROCEDURE STEPS`1`Note`1 4 4 20007 2
|
||||
-- 2869 `0POP05-EO-EO20`ADDENDUM 3`2`RNO` 1 5 20040 1
|
||||
-- 2863 `0POP05-EO-EO20`ADDENDUM 3`1`RNO` 1 5 20040 2
|
||||
-->389 `0POP05-EO-EC21`PROCEDURE STEPS`1 46 6 20002 1
|
||||
-- 224 `0POP05-EO-EO30`PROCEDURE STEPS`1 46 6 20002 2
|
||||
-- 8736 `0POP05-EO-FRH1`PROCEDURE STEPS`28`2`Table` 1 7 20008 1
|
||||
-- 6911 `0POP05-EO-EC32`PROCEDURE STEPS`11`2`Table` 1 7 20008 2
|
||||
*/
|
||||
/* -- Delete Parts <20> Only Step / Sub-step
|
||||
select * from (
|
||||
select PP.ItemID,dbo.ve_GetShortPath(PP.ItemID) Path,dbo.ve_GetSiblingCount(PP.ItemID) Siblings , PP.FromType, CC.Type,
|
||||
row_number()over(partition by FromType order by dbo.ve_GetSiblingCount(PP.ItemID) desc) RowNumber
|
||||
from Parts PP
|
||||
join Items II on PP.ItemID = II.ItemID
|
||||
join Contents CC on CC.ContentID = II.ContentID
|
||||
where II.ItemID not in(Select PreviousID from Items where PreviousID is not null)
|
||||
) t1
|
||||
where RowNumber < 3
|
||||
order by FromType,RowNumber
|
||||
-- ItemID Path Siblings FromType Type RowNumber
|
||||
-- 273 `0POP05-EO-EO00`PROCEDURE STEPS`21`Caution`1 1 3 20006 1
|
||||
-- 393 `0POP05-EO-ES00`PROCEDURE STEPS`2`Caution`1 1 3 20006 2
|
||||
-- 9685 `0POP05-EO-FRZ3`PROCEDURE STEPS`3`Note`1 1 4 20007 1
|
||||
-- 9658 `0POP05-EO-FRZ2`PROCEDURE STEPS`1`Note`1 1 4 20007 2
|
||||
-->182 `0POP05-EO-EO00`PROCEDURE STEPS`9`1`RNO` 1 5 20040 1
|
||||
-- 183 `0POP05-EO-EO00`PROCEDURE STEPS`9`2`RNO` 1 5 20040 2
|
||||
-- 9912 `0POP05-EO-FRI3`PROCEDURE STEPS`2`4`2`RNO``1 1 6 20024 1
|
||||
-- 9914 `0POP05-EO-FRI3`PROCEDURE STEPS`2`4`1`RNO``1 1 6 20024 2
|
||||
-- 383 `0POP05-EO-ES00`PROCEDURE STEPS`1`Table` 1 7 20008 1
|
||||
-- 2362 `0POP05-EO-ES12`PROCEDURE STEPS`13`2`Table` 1 7 20008 2
|
||||
*/
|
||||
/* -- External Transitions & next step (add Annotations)
|
||||
select II.ItemID,dbo.ve_GetShortPath(II.ItemID) Path,dbo.ve_GetShortPath(PP.ItemID) NextPath, dbo.ve_GetChildCount(II.ItemID) ChildCount
|
||||
, (Select count(*) from vefn_FindExternalTransitions(II.ItemID)) ExternalTransCount
|
||||
from Items II join Transitions TT on II.ContentID = TT.FromID
|
||||
left join Items PP on II.ItemID = PP.PreviousID
|
||||
where PP.ItemID is not null AND dbo.ve_GetChildCount(II.ItemID) > 1
|
||||
AND (Select count(*) from vefn_FindExternalTransitions(II.ItemID)) > 0
|
||||
-- 1406 `0POP05-EO-ES05`PROCEDURE STEPS`25`4 `0POP05-EO-ES05`PROCEDURE STEPS`25`5 ChildCount=2 ExternalTrans=2
|
||||
-- 2350 `0POP05-EO-ES12`PROCEDURE STEPS`12 `0POP05-EO-ES12`PROCEDURE STEPS`13 ChildCount=2 ExternalTrans=2
|
||||
-- 3079 `0POP05-EO-EO30`PROCEDURE STEPS`7`9 `0POP05-EO-EO30`PROCEDURE STEPS`7`10 ChildCount=4 ExternalTrans=1
|
||||
-->5167 `0POP05-EO-EC02`PROCEDURE STEPS`12 `0POP05-EO-EC02`PROCEDURE STEPS`13 ChildCount=3 ExternalTrans=2
|
||||
-- 8563 `0POP05-EO-FRH1`PROCEDURE STEPS`7 `0POP05-EO-FRH1`PROCEDURE STEPS`8 ChildCount=2 ExternalTrans=2
|
||||
-- 8614 `0POP05-EO-FRH1`PROCEDURE STEPS`14 `0POP05-EO-FRH1`PROCEDURE STEPS`15 ChildCount=2 ExternalTrans=1
|
||||
-- 9541 `0POP05-EO-FRZ1`PROCEDURE STEPS`2 `0POP05-EO-FRZ1`PROCEDURE STEPS`3 ChildCount=2 ExternalTrans=2*/
|
||||
/* -- Steps or Children with Annotations
|
||||
select top 5 ItemID, dbo.ve_GetShortPath(ItemID) Path, Annotations from (
|
||||
select ItemID ,
|
||||
(select Count(*) from vefn_ChildItems(II.ItemID) CI join Annotations AA on AA.ItemID = CI.ItemID) Annotations
|
||||
from vefn_AllHighLevelSteps() II
|
||||
) T1
|
||||
ORDER BY Annotations DESC
|
||||
-- ItemID Path Annotations
|
||||
-->105 `0POP05-EO-EC00`PROCEDURE STEPS`1 1
|
||||
-- 505 `0POP05-EO-ES01`PROCEDURE STEPS`6 1
|
||||
-- 740 `0POP05-EO-ES02`PROCEDURE STEPS`3 1
|
||||
-- 1198 `0POP05-EO-ES05`PROCEDURE STEPS`8 1
|
||||
-- 1731 `0POP05-EO-EO10`PROCEDURE STEPS`13 1
|
||||
*/
|
||||
/* -- Steps or Children with Details
|
||||
-- No Data
|
||||
*/
|
||||
/* -- Steps or Children with Entries
|
||||
select top 5 ItemID, dbo.ve_GetShortPath(ItemID) Path
|
||||
from Items II
|
||||
join Entries EE on EE.ContentID = II.ContentID
|
||||
-- ItemID Path
|
||||
-->377 `0POP05-EO-EO00`ADDENDUM 4
|
||||
-- 1926 `0POP05-EO-EO10`ADDENDUM 4
|
||||
-- 2569 `0POP05-EO-ES12`ADDENDUM 9
|
||||
-- 2648 `0POP05-EO-ES13`ADDENDUM 2
|
||||
-- 3756 `0POP05-EO-ES31`ADDENDUM 2
|
||||
*/
|
||||
/* -- Steps or Children with ROUsages
|
||||
select top 5 * From (
|
||||
select ItemID, dbo.ve_GetShortPath(ItemID) Path, (Select Count(*) from ROUsages RO where RO.ContentID = II.ContentID) ROs
|
||||
From Items II
|
||||
WHERE ContentID in(Select ContentID from ROUsages)
|
||||
) T1 Order by ROs Desc
|
||||
-- ItemID Path ROs
|
||||
-->4940 `0POP05-EO-EC01`PROCEDURE STEPS`9`1`RNO``1 5
|
||||
-- 5115 `0POP05-EO-EC02`PROCEDURE STEPS`7`1`RNO``1 5
|
||||
-- 5118 `0POP05-EO-EC02`PROCEDURE STEPS`7`1`RNO``4 5
|
||||
-- 2429 `0POP05-EO-ES12`PROCEDURE STEPS`17`4 4
|
||||
-- 2433 `0POP05-EO-ES12`PROCEDURE STEPS`17`8 4
|
||||
*/
|
||||
/* -- Steps or Children with internal Transitions
|
||||
select top 5 ItemID,dbo.ve_GetShortPath(ItemID) Path, InternalTransitions
|
||||
from vefn_AllHighLevelStepTransitions() order by InternalTransitions Desc
|
||||
-- ItemID Path InternalTransitions
|
||||
-->2984 `0POP05-EO-EO30`PROCEDURE STEPS`7 5
|
||||
-- 4454 `0POP05-EO-EC00`PROCEDURE STEPS`16 5
|
||||
-- 774 `0POP05-EO-ES02`PROCEDURE STEPS`10 4
|
||||
-- 898 `0POP05-EO-ES02`PROCEDURE STEPS`19 4
|
||||
-- 1064 `0POP05-EO-ES03`PROCEDURE STEPS`6 4
|
||||
*/
|
||||
/* -- Steps or Children with Parts
|
||||
select top 5 * from (
|
||||
select ItemID,dbo.ve_GetShortPath(ItemID) Path ,ExternalTransitions, ExternalChildTransitions, dbo.ve_GetChildCount(ItemID) Children
|
||||
from vefn_AllHighLevelStepTransitions()
|
||||
) T1 order by Children Desc
|
||||
-- ItemID Path ExternalTransitions ExternalChildTransitions Children
|
||||
-->5624 `0POP05-EO-EC12`PROCEDURE STEPS`5 3 0 74
|
||||
-- 389 `0POP05-EO-EC21`PROCEDURE STEPS`1 2 0 70
|
||||
-- 7528 `0POP05-EO-FRS1`PROCEDURE STEPS`4 1 0 66
|
||||
-- 5645 `0POP05-EO-EC12`PROCEDURE STEPS`4 1 0 65
|
||||
-- 4840 `0POP05-EO-EC01`PROCEDURE STEPS`4 2 0 64
|
||||
*/
|
||||
/* -- Steps or Children with XContents
|
||||
--Any will do
|
||||
*/
|
||||
/* -- Steps or Children with PreviousID
|
||||
--Steps with Children
|
||||
*/
|
||||
/* -- Steps or Children with Items
|
||||
--Any will do
|
||||
*/
|
||||
/* -- Steps or Children with Contents
|
||||
--Any will do
|
||||
*/
|
9
PROMS/SQL/FindSectionGiventFormatAndDocstyle.sql
Normal file
9
PROMS/SQL/FindSectionGiventFormatAndDocstyle.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
--vesp_getformatfields 'ATTACHNUM1'
|
||||
|
||||
--select formatid, count(*) cnt from vefn_getversionformatitems('') where formatid in (39, 38, 41, 136) group by formatid
|
||||
|
||||
select vn.foldername, dbo.ve_getshortpathfromcontentid(cc.contentid)
|
||||
from vefn_getversionformatitems('') vi
|
||||
join vefn_getversionnames() vn on vi.versionid = vn.versionid
|
||||
join contents cc on cc.contentid = vi.contentid
|
||||
where (vi.formatid = 41 and cc.type = 10004) or (vi.formatid = 136 and cc.type = 10005)
|
3
PROMS/SQL/FindTablesWithDuplicateROUsages.sql
Normal file
3
PROMS/SQL/FindTablesWithDuplicateROUsages.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select *, case when cast(data as nvarchar(max)) like '%mergedranges%' then 'true' else 'false' end merged from Grids GG
|
||||
Join ROUsages RU ON RU.ContentID =GG.ContentID
|
||||
where cast(data as nvarchar(max)) like '%:' + cast(rousageid as varchar(10)) + '%:' + cast(rousageid as varchar(10)) + '%'
|
5
PROMS/SQL/FindTransitionsToBullets.sql
Normal file
5
PROMS/SQL/FindTransitionsToBullets.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
Select dbo.ve_GetPathFromContentID(t.Fromid), C.Type
|
||||
FROM [Items] I
|
||||
Join Contents C on C.ContentID = I.ContentID
|
||||
JOIN Transitions t on t.ToID = I.ItemID -- or t.RangeID = I.ItemID
|
||||
WHERE C.Type in (20004, 20005, 20006, 20007, 20008, 20010, 20011, 20019, 20030, 20031, 20035)
|
113
PROMS/SQL/FixFor256Number.SQL
Normal file
113
PROMS/SQL/FixFor256Number.SQL
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
/****** Object: StoredProcedure [updateContent] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[updateContent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [updateContent];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[updateContent]
|
||||
|
||||
(
|
||||
@ContentID int,
|
||||
@Number nvarchar(256)=null,
|
||||
@Text nvarchar(MAX)=null,
|
||||
@Type int=null,
|
||||
@FormatID int=null,
|
||||
@Config nvarchar(MAX)=null,
|
||||
@DTS datetime,
|
||||
@UserID nvarchar(100),
|
||||
@LastChanged timestamp,
|
||||
@newLastChanged timestamp output
|
||||
)
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION
|
||||
UPDATE [Contents]
|
||||
SET
|
||||
[Number]=@Number,
|
||||
[Text]=@Text,
|
||||
[Type]=@Type,
|
||||
[FormatID]=@FormatID,
|
||||
[Config]=@Config,
|
||||
[DTS]=@DTS,
|
||||
[UserID]=@UserID
|
||||
WHERE [ContentID]=@ContentID AND [LastChanged]=@LastChanged
|
||||
IF @@ROWCOUNT = 0
|
||||
BEGIN
|
||||
IF NOT exists(select * from [Contents] WHERE [ContentID]=@ContentID)
|
||||
RAISERROR('Content record has been deleted by another user', 16, 1)
|
||||
ELSE
|
||||
RAISERROR('Content has been edited by another user', 16, 1)
|
||||
END
|
||||
|
||||
SELECT @newLastChanged=[LastChanged]
|
||||
FROM [Contents] WHERE [ContentID]=@ContentID
|
||||
|
||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||
END TRY
|
||||
BEGIN CATCH -- Catch Block
|
||||
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: updateContent Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: updateContent Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [addContent] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addContent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [addContent];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[addContent]
|
||||
|
||||
(
|
||||
@Number nvarchar(256)=null,
|
||||
@Text nvarchar(MAX)=null,
|
||||
@Type int=null,
|
||||
@FormatID int=null,
|
||||
@Config nvarchar(MAX)=null,
|
||||
@DTS datetime,
|
||||
@UserID nvarchar(100),
|
||||
@newContentID int output,
|
||||
@newLastChanged timestamp output
|
||||
)
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION
|
||||
INSERT INTO [Contents]
|
||||
(
|
||||
[Number],
|
||||
[Text],
|
||||
[Type],
|
||||
[FormatID],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Number,
|
||||
@Text,
|
||||
@Type,
|
||||
@FormatID,
|
||||
@Config,
|
||||
@DTS,
|
||||
@UserID
|
||||
)
|
||||
SELECT @newContentID= SCOPE_IDENTITY()
|
||||
SELECT @newLastChanged=[LastChanged]
|
||||
FROM [Contents] WHERE [ContentID]=@newContentID
|
||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||
END TRY
|
||||
BEGIN CATCH -- Catch Block
|
||||
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: addContent Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: addContent Error on Creation'
|
||||
GO
|
47
PROMS/SQL/FixInternalTest.sql
Normal file
47
PROMS/SQL/FixInternalTest.sql
Normal file
@@ -0,0 +1,47 @@
|
||||
USE [VEPROMS]
|
||||
DECLARE @RowsAffected int
|
||||
DECLARE @InternalTransitions TABLE
|
||||
(
|
||||
TransitionID int,
|
||||
FromID int, -- contentid
|
||||
TranType int,
|
||||
ToID int,
|
||||
RangeID int,
|
||||
OldTransitionID int
|
||||
)
|
||||
Insert into @InternalTransitions select * from vefn_FindInternalTransitionsForCopy(10356)
|
||||
SELECT * From Children
|
||||
SELECT * From @InternalTransitions
|
||||
SELECT C1.Text, IT.OldTransitionID,IT.TranType,IT.ToID,IT.RangeID, IT.[TransitionID], NNT.ItemID, NNR.ItemID
|
||||
FROM CONTENTS C1
|
||||
JOIN @InternalTransitions IT ON C1.ContentID = IT.FromID
|
||||
LEFT JOIN Children NNT on IT.ToID = NNT.NewItemID
|
||||
LEFT JOIN Children NNR on IT.RangeID = NNR.NewItemID --C2 ON CC.ContentID = C2.ContentID
|
||||
IF (SELECT COUNT(*) from @InternalTransitions) > 0 -- found transitions internal to copied step
|
||||
BEGIN
|
||||
SET @RowsAffected=1
|
||||
WHILE @RowsAffected > 0
|
||||
BEGIN
|
||||
-- Need to update the 'to' and 'range' transition fields within the content records
|
||||
Update CC SET [TEXT] = C2.NewText
|
||||
FROM CONTENTS CC
|
||||
JOIN (SELECT C1.ContentID, .dbo.vefn_FixTransitionTextForCopy([Text], IT.OldTransitionID,IT.TranType,NNT.ItemID,NNR.ItemID,IT.[TransitionID], IT.ToID,IT.RangeID) NewText
|
||||
FROM CONTENTS C1
|
||||
JOIN @InternalTransitions IT ON C1.ContentID = IT.FromID
|
||||
LEFT JOIN Children NNT on IT.ToID = NNT.NewItemID
|
||||
LEFT JOIN Children NNR on IT.RangeID = NNR.NewItemID) C2 ON CC.ContentID = C2.ContentID
|
||||
WHERE [TEXT] <> C2.NewText
|
||||
SET @RowsAffected = @@RowCount
|
||||
END
|
||||
END
|
||||
/*
|
||||
UPDATE CC SET [TEXT] = C2.NewText
|
||||
FROM CONTENTS CC
|
||||
JOIN (SELECT C1.ContentID, .dbo.vefn_FixTransitionTextCopy(C1.Text, CAST(TR.[Config] as int), TR.TranType, TR.[ToID], TR.[RangeID],TR.[TransitionID]) NewText
|
||||
FROM CONTENTS C1
|
||||
JOIN @Children NN on C1.ContentID = NN.NewContentID
|
||||
JOIN Transitions TR on NN.NewContentID = TR.FromID) C2 ON CC.ContentID = C2.ContentID
|
||||
WHERE [TEXT] <> C2.NewText
|
||||
SET @RowsAffected = @@RowCount
|
||||
END
|
||||
*/
|
1
PROMS/SQL/FmtXMLGetC0.sql
Normal file
1
PROMS/SQL/FmtXMLGetC0.sql
Normal file
@@ -0,0 +1 @@
|
||||
select formatid, name, genmac,v.query('.') circle from formats cross apply genmac.nodes('//g[@id="C0"]') tmpxml(v)
|
1
PROMS/SQL/Formats/GetFormatFieldValues.sql
Normal file
1
PROMS/SQL/Formats/GetFormatFieldValues.sql
Normal file
@@ -0,0 +1 @@
|
||||
vesp_getformatfieldsbysteptype stboxindex
|
1
PROMS/SQL/Formats/GetFormatFieldValuesUsingValue.sql
Normal file
1
PROMS/SQL/Formats/GetFormatFieldValuesUsingValue.sql
Normal file
@@ -0,0 +1 @@
|
||||
vesp_getformatfieldsbysteptype 'Date Time Note'
|
28
PROMS/SQL/FullTextSearchStatus.sql
Normal file
28
PROMS/SQL/FullTextSearchStatus.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
select case FullTextCatalogProperty('MyCatalog', 'PopulateStatus')
|
||||
|
||||
when 0 then 'Idle'
|
||||
|
||||
when 1 then 'Full population in progress'
|
||||
|
||||
when 2 then 'Paused'
|
||||
|
||||
when 3 then 'Throttled'
|
||||
|
||||
when 4 then 'Recovering'
|
||||
|
||||
when 5 then 'Shutdown'
|
||||
|
||||
when 6 then 'Incremental population in progress'
|
||||
|
||||
when 7 then 'Building index'
|
||||
|
||||
when 8 then 'Disk is full. Paused.'
|
||||
|
||||
when 9 then 'Change tracking'
|
||||
|
||||
else 'Error reading FullTextCatalogProperty PopulateStatus'
|
||||
|
||||
end
|
||||
|
||||
|
||||
select FullTextCatalogProperty('MyCatalog', 'PopulateStatus')
|
62
PROMS/SQL/FullTextSetup.sql
Normal file
62
PROMS/SQL/FullTextSetup.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
EXEC sp_fulltext_database 'enable'
|
||||
go
|
||||
CREATE FULLTEXT CATALOG FT_Catalog_JSJ
|
||||
go
|
||||
--DROP FULLTEXT INDEX ON CONTENTS
|
||||
GO
|
||||
CREATE FULLTEXT INDEX ON Contents
|
||||
(
|
||||
Text
|
||||
Language 1033
|
||||
)
|
||||
KEY INDEX PK_Contents ON FT_Catalog
|
||||
WITH CHANGE_TRACKING AUTO
|
||||
GO
|
||||
--DROP FULLTEXT INDEX ON Documents
|
||||
CREATE FULLTEXT INDEX ON Documents
|
||||
(
|
||||
DocAscii
|
||||
Language 1033
|
||||
)
|
||||
KEY INDEX PK_Documents ON FT_Catalog
|
||||
WITH CHANGE_TRACKING AUTO
|
||||
GO
|
||||
*/
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"FOLLOW*"') -- prefix Follow
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"RCP*"') -- prefix Follow
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"FOLLOW"') -- exact Follow
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'PORV AND SG') -- boolean
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'PORV NEAR SG') -- boolean
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"SG AND PORV"') -- boolean
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"SG*" AND "PORV*"') -- boolean
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"SG" AND "PORV"') -- boolean
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"SG*" AND "PORV*"') -- boolean
|
||||
AND NOT CONTAINS(text, '"SG" AND "PORV"') -- boolean
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"SG PORV"') -- boolean
|
||||
SELECT * FROM contents WHERE text like '%SG PORV%' -- SQL Search
|
||||
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'FORMSOF(INFLECTIONAL, "foot")'); -- inflectional foot
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"run*"'); -- prefix run
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'FORMSOF(INFLECTIONAL, "run")'); -- inflectional run
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"run*"')
|
||||
AND NOT CONTAINS(text, 'FORMSOF(INFLECTIONAL, "run")'); -- prefix run and not inflectional run
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"vacuum decrease*"'); -- prefix vacuum decrease
|
||||
|
||||
SELECT count(*) DG_or_DieselGenerator FROM contents where text like '%DG%' OR text like '%DIESEL GENERATOR%'
|
||||
SELECT count(*) DG FROM contents where text like '%DG%'
|
||||
SELECT count(*) DieselGenerator FROM contents where text like '%DIESEL GENERATOR%'
|
||||
SELECT * FROM contents where text like '%DIESEL GENERATOR%'
|
||||
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'FORMSOF(THESAURUS, "DG*")'); --
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'FORMSOF(THESAURUS, "DIESEL GENERATOR")'); --
|
||||
SELECT * FROM contents WHERE FREETEXT(text, '"DIESEL GENERATOR*"'); --
|
||||
SELECT * FROM contents WHERE FREETEXT(text, '"DG*"'); --
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'FORMSOF(THESAURUS, "SG")'); --
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'FORMSOF(THESAURUS, "STEAM GENERATOR")'); --
|
||||
|
||||
EXEC sp_fulltext_load_thesaurus_file 1033;
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"RUN*" and "PUMP*"'); --
|
||||
SELECT * FROM contents WHERE CONTAINS(text, 'FORMSOF(INFLECTIONAL, "run") and "PUMP*"'); --
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"RUN*" and "PUMP*"') --
|
||||
AND NOT CONTAINS(text, 'FORMSOF(INFLECTIONAL, "run") and "PUMP*"'); --
|
6
PROMS/SQL/GenMacNodes.sql
Normal file
6
PROMS/SQL/GenMacNodes.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
Select FormatID, Name
|
||||
, v.value('./@id', 'varchar(255)') Macro
|
||||
, v.query('.') Commands
|
||||
FROM Formats
|
||||
CROSS APPLY GenMac.nodes('//g') TempXML(v)
|
||||
where v.value('./@id', 'varchar(255)')='M23'
|
6
PROMS/SQL/GenmacMacro.sql
Normal file
6
PROMS/SQL/GenmacMacro.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
Select FormatID, Name
|
||||
, v.value('./@id', 'varchar(255)') Macro
|
||||
, v.query('.') Commands
|
||||
FROM Formats
|
||||
CROSS APPLY GenMac.nodes('//g') TempXML(v)
|
||||
where v.value('./@id', 'varchar(255)')='C22'
|
12
PROMS/SQL/GenmacPivot.sql
Normal file
12
PROMS/SQL/GenmacPivot.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
SELECT * FROM (
|
||||
Select FormatID, Name
|
||||
, v.value('./@id', 'varchar(255)') Macro
|
||||
FROM Formats
|
||||
CROSS APPLY GenMac.nodes('//g') TempXML(v)
|
||||
--where v.value('./@TransFormat', 'varchar(255)') not like '%{Last Step}%'
|
||||
) AS SRC
|
||||
PIVOT( Count(Macro) FOR Macro IN (
|
||||
["", 34],["",34],[B1],[B2],[B3],[B4],[B5],[B6],[B7],[B8],[C0],[C10],[C11],
|
||||
[C12],[C2],[C22],[C3],[C4],[C5],[C6],[C7],[C8],[C9],[CHKBOX,12],[H1],[H2],
|
||||
[H3],[H4],[H5],[m35],[m36],[PLNTPLMAC,0],[PLNTPLMAC2,0]
|
||||
)) AS PVT1 Order by case when Name='Base' then 0 else 1 end, Name
|
6
PROMS/SQL/GetChildrenOfContentText.sql
Normal file
6
PROMS/SQL/GetChildrenOfContentText.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
select dbo.ve_getshortpath(ii.itemid) location, (select count(*) from vefn_ChildItems(ii.ItemID)) children
|
||||
from Contents cc
|
||||
join Items ii on ii.contentid = cc.contentid
|
||||
where type = 20043
|
||||
and text in ('DEVICE', 'SETPOINT')
|
||||
order by (select count(*) from vefn_ChildItems(ii.ItemID)) desc
|
12
PROMS/SQL/GetDefaultStepSection.sql
Normal file
12
PROMS/SQL/GetDefaultStepSection.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
select grandparentname, parentname, foldername, number, procid, sectnum, secttitle, sectionstart, xsection.value('@OriginalSteps', 'char(1)') OriginalSteps from
|
||||
(select t1.*, cc.number sectnum, cc.text secttitle, cast(cc.config as xml) xconfig from
|
||||
(select grandparentname, parentname, foldername, number, procid, xprocedure.value('@SectionStart', 'int') sectionstart from
|
||||
(select number, cc.contentid, itemid procid, cast(config as xml) xconfig from contents cc
|
||||
join items ii on ii.contentid = cc.contentid where type = 0) t1
|
||||
outer apply xconfig.nodes('//Procedure') tprocedure(xprocedure)
|
||||
join vefn_getversionitems('') vi on vi.contentid = t1.contentid
|
||||
join vefn_getversionnames() vn on vn.versionid = vi.versionid) t1
|
||||
left join items ii on ii.itemid = t1.sectionstart
|
||||
left join contents cc on cc.contentid = ii.contentid
|
||||
where sectionstart is not null) t1
|
||||
cross apply xconfig.nodes('//Section') tsection(xsection)
|
8
PROMS/SQL/GetDefaultStepSectionForProc.sql
Normal file
8
PROMS/SQL/GetDefaultStepSectionForProc.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
select versionid, procid, itemid, xsection.value('@OriginalSteps', 'char(1)') originalsteps, xprocedure.value('@SectionStart', 'int') sectionstart from
|
||||
(select versionid, procid, vi.itemid, cast(cc.config as xml) xconfig, cast(pcc.config as xml) xpconfig from vefn_GetVersionProcedureItems('') vi
|
||||
join contents cc on vi.contentid = cc.contentid
|
||||
join items pii on vi.procid = pii.itemid
|
||||
join contents pcc on pcc.contentid = pii.contentid
|
||||
where procid = 133172 and cc.type between 10000 and 19999) t1
|
||||
cross apply xconfig.nodes('//Section') tsection(xsection)
|
||||
cross apply xpconfig.nodes('//Procedure') tprocedure(xprocedure)
|
7
PROMS/SQL/GetTableWidth.sql
Normal file
7
PROMS/SQL/GetTableWidth.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
select .dbo.ve_getShortPathFromContentID(CC.ContentID) Location, sum(xWidth.value('.','int')) TotalWidth
|
||||
from grids GG
|
||||
Join contents CC on CC.ContentID = GG.ContentID
|
||||
cross apply data.nodes('//Column/Width') tWidth(xWidth)
|
||||
Where CC.Type = 20010
|
||||
group by CC.ContentID
|
||||
order by totalWidth Desc
|
4
PROMS/SQL/GetUsersAndSecurtyGroups.sql
Normal file
4
PROMS/SQL/GetUsersAndSecurtyGroups.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
select gg.GroupName, count(*) howmany from users uu
|
||||
join Memberships mm on uu.UID = mm.uid
|
||||
join Groups gg on mm.GID = gg.GID
|
||||
group by gg.GroupName
|
2
PROMS/SQL/ListWordDocSizesAndIds.sql
Normal file
2
PROMS/SQL/ListWordDocSizesAndIds.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
select contentid, dd.DocID,len(doccontent) from documents dd
|
||||
join entries ee on ee.docid = dd. DocID order by len(DocContent) desc
|
16584
PROMS/SQL/PROMS2010_jcb.SQL
Normal file
16584
PROMS/SQL/PROMS2010_jcb.SQL
Normal file
File diff suppressed because it is too large
Load Diff
16583
PROMS/SQL/PROMS2010_jcb.SQL.bak
Normal file
16583
PROMS/SQL/PROMS2010_jcb.SQL.bak
Normal file
File diff suppressed because it is too large
Load Diff
3010
PROMS/SQL/PROMStoAPPR.sql
Normal file
3010
PROMS/SQL/PROMStoAPPR.sql
Normal file
File diff suppressed because it is too large
Load Diff
2784
PROMS/SQL/PROMStoCM.sql.bak
Normal file
2784
PROMS/SQL/PROMStoCM.sql.bak
Normal file
File diff suppressed because it is too large
Load Diff
4
PROMS/SQL/PartsWithSectionAndSteps.sql
Normal file
4
PROMS/SQL/PartsWithSectionAndSteps.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
select contentid, count(*) howmany, min(fromtype) mnfrom, max(fromtype) mxfrom
|
||||
from parts
|
||||
group by contentid
|
||||
having min(fromtype) <= 2 and max(fromtype) >= 3
|
669
PROMS/SQL/PdfFieldForDocuments.sql
Normal file
669
PROMS/SQL/PdfFieldForDocuments.sql
Normal file
@@ -0,0 +1,669 @@
|
||||
ALTER TABLE [Documents] ADD [DocPdf] [varbinary](max) NULL
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [addDocument] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addDocument]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [addDocument];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[addDocument]
|
||||
|
||||
(
|
||||
@LibTitle nvarchar(1024)=null,
|
||||
@DocContent varbinary(MAX)=null,
|
||||
@DocAscii nvarchar(MAX)=null,
|
||||
@Config nvarchar(MAX)=null,
|
||||
@DTS datetime,
|
||||
@UserID nvarchar(100),
|
||||
@FileExtension nvarchar(10),
|
||||
@DocPdf varbinary(MAX)=null,
|
||||
@newDocID int output,
|
||||
@newLastChanged timestamp output
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION
|
||||
INSERT INTO [Documents]
|
||||
(
|
||||
[LibTitle],
|
||||
[DocContent],
|
||||
[DocAscii],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[FileExtension],
|
||||
[DocPdf]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@LibTitle,
|
||||
@DocContent,
|
||||
@DocAscii,
|
||||
@Config,
|
||||
@DTS,
|
||||
@UserID,
|
||||
@FileExtension,
|
||||
@DocPdf
|
||||
)
|
||||
SELECT @newDocID= SCOPE_IDENTITY()
|
||||
SELECT @newLastChanged=[LastChanged]
|
||||
FROM [Documents] WHERE [DocID]=@newDocID
|
||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||
END TRY
|
||||
BEGIN CATCH -- Catch Block
|
||||
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: addDocument Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: addDocument Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [getContent] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getContent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getContent];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getContent]
|
||||
|
||||
(
|
||||
@ContentID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[ContentID],
|
||||
[Number],
|
||||
[Text],
|
||||
[Type],
|
||||
[FormatID],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
|
||||
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
|
||||
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
|
||||
FROM [Contents]
|
||||
WHERE [ContentID]=@ContentID
|
||||
|
||||
SELECT
|
||||
[Details].[DetailID],
|
||||
[Details].[ContentID],
|
||||
[Details].[ItemType],
|
||||
[Details].[Text],
|
||||
[Details].[Config],
|
||||
[Details].[DTS],
|
||||
[Details].[UserID],
|
||||
[Details].[LastChanged]
|
||||
FROM [Details]
|
||||
WHERE
|
||||
[Details].[ContentID]=@ContentID
|
||||
|
||||
|
||||
SELECT
|
||||
[Entries].[ContentID],
|
||||
[Entries].[DocID],
|
||||
[Entries].[DTS],
|
||||
[Entries].[UserID],
|
||||
[Entries].[LastChanged],
|
||||
[Documents].[LibTitle] [Document_LibTitle],
|
||||
[Documents].[DocContent] [Document_DocContent],
|
||||
[Documents].[DocAscii] [Document_DocAscii],
|
||||
[Documents].[Config] [Document_Config],
|
||||
[Documents].[DTS] [Document_DTS],
|
||||
[Documents].[UserID] [Document_UserID],
|
||||
[Documents].[FileExtension] [Document_FileExtension],
|
||||
[Documents].[DocPdf] [Document_DocPdf]
|
||||
FROM [Entries]
|
||||
JOIN [Documents] ON
|
||||
[Documents].[DocID]=[Entries].[DocID]
|
||||
WHERE
|
||||
[Entries].[ContentID]=@ContentID
|
||||
|
||||
|
||||
SELECT
|
||||
[Items].[ItemID],
|
||||
[Items].[PreviousID],
|
||||
[Items].[ContentID],
|
||||
[Items].[DTS],
|
||||
[Items].[UserID],
|
||||
[Items].[LastChanged]
|
||||
FROM [Items]
|
||||
WHERE
|
||||
[Items].[ContentID]=@ContentID
|
||||
|
||||
|
||||
SELECT
|
||||
[Parts].[ContentID],
|
||||
[Parts].[FromType],
|
||||
[Parts].[ItemID],
|
||||
[Parts].[DTS],
|
||||
[Parts].[UserID],
|
||||
[Parts].[LastChanged],
|
||||
[Items].[PreviousID] [Item_PreviousID],
|
||||
[Items].[ContentID] [Item_ContentID],
|
||||
[Items].[DTS] [Item_DTS],
|
||||
[Items].[UserID] [Item_UserID]
|
||||
FROM [Parts]
|
||||
JOIN [Items] ON
|
||||
[Items].[ItemID]=[Parts].[ItemID]
|
||||
WHERE
|
||||
[Parts].[ContentID]=@ContentID
|
||||
|
||||
|
||||
SELECT
|
||||
[RoUsages].[ROUsageID],
|
||||
[RoUsages].[ContentID],
|
||||
[RoUsages].[ROID],
|
||||
[RoUsages].[Config],
|
||||
[RoUsages].[DTS],
|
||||
[RoUsages].[UserID],
|
||||
[RoUsages].[LastChanged],
|
||||
[RoUsages].[RODbID],
|
||||
[RODbs].[ROName] [RODb_ROName],
|
||||
[RODbs].[FolderPath] [RODb_FolderPath],
|
||||
[RODbs].[DBConnectionString] [RODb_DBConnectionString],
|
||||
[RODbs].[Config] [RODb_Config],
|
||||
[RODbs].[DTS] [RODb_DTS],
|
||||
[RODbs].[UserID] [RODb_UserID]
|
||||
FROM [RoUsages]
|
||||
JOIN [RODbs] ON
|
||||
[RODbs].[RODbID]=[RoUsages].[RODbID]
|
||||
WHERE
|
||||
[RoUsages].[ContentID]=@ContentID
|
||||
|
||||
|
||||
SELECT
|
||||
[Transitions].[TransitionID],
|
||||
[Transitions].[FromID],
|
||||
[Transitions].[ToID],
|
||||
[Transitions].[RangeID],
|
||||
[Transitions].[TranType],
|
||||
[Transitions].[Config],
|
||||
[Transitions].[DTS],
|
||||
[Transitions].[UserID],
|
||||
[Transitions].[LastChanged],
|
||||
[Items_RangeID].[PreviousID] [Item_RangeID_PreviousID],
|
||||
[Items_RangeID].[ContentID] [Item_RangeID_ContentID],
|
||||
[Items_RangeID].[DTS] [Item_RangeID_DTS],
|
||||
[Items_RangeID].[UserID] [Item_RangeID_UserID],
|
||||
[Items_ToID].[PreviousID] [Item_ToID_PreviousID],
|
||||
[Items_ToID].[ContentID] [Item_ToID_ContentID],
|
||||
[Items_ToID].[DTS] [Item_ToID_DTS],
|
||||
[Items_ToID].[UserID] [Item_ToID_UserID]
|
||||
FROM [Transitions]
|
||||
JOIN [Items] [Items_RangeID] ON
|
||||
[Items_RangeID].[ItemID]=[Transitions].[RangeID]
|
||||
JOIN [Items] [Items_ToID] ON
|
||||
[Items_ToID].[ItemID]=[Transitions].[ToID]
|
||||
WHERE
|
||||
[Transitions].[FromID]=@ContentID
|
||||
|
||||
|
||||
SELECT
|
||||
[ZContents].[ContentID],
|
||||
[ZContents].[OldStepSequence],
|
||||
[ZContents].[LastChanged]
|
||||
FROM [ZContents]
|
||||
WHERE
|
||||
[ZContents].[ContentID]=@ContentID
|
||||
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getContent Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getContent Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [getDocument] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDocument]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getDocument];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getDocument]
|
||||
|
||||
(
|
||||
@DocID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[DocID],
|
||||
[LibTitle],
|
||||
[DocContent],
|
||||
[DocAscii],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
[FileExtension],
|
||||
[DocPdf],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[DocID]=[Documents].[DocID]) [EntryCount]
|
||||
FROM [Documents]
|
||||
WHERE [DocID]=@DocID
|
||||
|
||||
SELECT
|
||||
[Entries].[ContentID],
|
||||
[Entries].[DocID],
|
||||
[Entries].[DTS],
|
||||
[Entries].[UserID],
|
||||
[Entries].[LastChanged],
|
||||
[Contents].[Number] [Content_Number],
|
||||
[Contents].[Text] [Content_Text],
|
||||
[Contents].[Type] [Content_Type],
|
||||
[Contents].[FormatID] [Content_FormatID],
|
||||
[Contents].[Config] [Content_Config],
|
||||
[Contents].[DTS] [Content_DTS],
|
||||
[Contents].[UserID] [Content_UserID]
|
||||
FROM [Entries]
|
||||
JOIN [Contents] ON
|
||||
[Contents].[ContentID]=[Entries].[ContentID]
|
||||
WHERE
|
||||
[Entries].[DocID]=@DocID
|
||||
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getDocument Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getDocument Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [getDocuments] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDocuments]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getDocuments];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getDocuments]
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[DocID],
|
||||
[LibTitle],
|
||||
[DocContent],
|
||||
[DocAscii],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
[FileExtension],
|
||||
[DocPdf],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[DocID]=[Documents].[DocID]) [EntryCount]
|
||||
FROM [Documents]
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getDocuments Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getDocuments Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [getEntriesByContentID] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getEntriesByContentID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getEntriesByContentID];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getEntriesByContentID]
|
||||
|
||||
(
|
||||
@ContentID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
|
||||
SELECT
|
||||
[Entries].[ContentID],
|
||||
[Entries].[DocID],
|
||||
[Entries].[DTS],
|
||||
[Entries].[UserID],
|
||||
[Entries].[LastChanged],
|
||||
[Documents].[LibTitle] [Document_LibTitle],
|
||||
[Documents].[DocContent] [Document_DocContent],
|
||||
[Documents].[DocAscii] [Document_DocAscii],
|
||||
[Documents].[Config] [Document_Config],
|
||||
[Documents].[DTS] [Document_DTS],
|
||||
[Documents].[UserID] [Document_UserID],
|
||||
[Documents].[FileExtension] [Document_FileExtension],
|
||||
[Documents].[DocPdf] [Document_DocPdf]
|
||||
FROM [Entries]
|
||||
JOIN [Documents] ON
|
||||
[Documents].[DocID]=[Entries].[DocID]
|
||||
WHERE
|
||||
[Entries].[ContentID]=@ContentID
|
||||
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getEntriesByContentID Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getEntriesByContentID Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [updateDocument] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[updateDocument]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [updateDocument];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[updateDocument]
|
||||
|
||||
(
|
||||
@DocID int,
|
||||
@LibTitle nvarchar(1024)=null,
|
||||
@DocContent varbinary(MAX)=null,
|
||||
@DocAscii nvarchar(MAX)=null,
|
||||
@Config nvarchar(MAX)=null,
|
||||
@DTS datetime,
|
||||
@UserID nvarchar(100),
|
||||
@LastChanged timestamp,
|
||||
@FileExtension nvarchar(10),
|
||||
@DocPdf varbinary(MAX)=null,
|
||||
@newLastChanged timestamp output
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION
|
||||
UPDATE [Documents]
|
||||
SET
|
||||
[LibTitle]=@LibTitle,
|
||||
[DocContent]=@DocContent,
|
||||
[DocAscii]=@DocAscii,
|
||||
[Config]=@Config,
|
||||
[DTS]=@DTS,
|
||||
[UserID]=@UserID,
|
||||
[FileExtension]=@FileExtension,
|
||||
[DocPdf]=@DocPdf
|
||||
WHERE [DocID]=@DocID AND [LastChanged]=@LastChanged
|
||||
IF @@ROWCOUNT = 0
|
||||
BEGIN
|
||||
IF NOT exists(select * from [Documents] WHERE [DocID]=@DocID)
|
||||
RAISERROR('Document record has been deleted by another user', 16, 1)
|
||||
ELSE
|
||||
RAISERROR('Document has been edited by another user', 16, 1)
|
||||
END
|
||||
|
||||
SELECT @newLastChanged=[LastChanged]
|
||||
FROM [Documents] WHERE [DocID]=@DocID
|
||||
|
||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||
END TRY
|
||||
BEGIN CATCH -- Catch Block
|
||||
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: updateDocument Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: updateDocument Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getLibraryDocuments] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getLibraryDocuments]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getLibraryDocuments];
|
||||
GO
|
||||
|
||||
--getLibraryDocuments
|
||||
CREATE PROCEDURE [dbo].[getLibraryDocuments]
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[DocID],
|
||||
[LibTitle],
|
||||
[DocContent],
|
||||
[DocAscii],
|
||||
[FileExtension],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
[DocPdf],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[DocID]=[Documents].[DocID]) [EntryCount]
|
||||
FROM [Documents] where [LibTitle] <> '' order by [LibTitle]
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getLibraryDocuments Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getLibraryDocuments Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [CopyItemAndChildren] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[CopyItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [CopyItemAndChildren];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[CopyItemAndChildren]
|
||||
(
|
||||
@StartItemID INT,
|
||||
@DestFormatID INT,
|
||||
@UserID NVARCHAR(100),
|
||||
@NewStartItemID int output
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
|
||||
--+-----------------------------------------------------------------+
|
||||
--<EFBFBD> BEGIN TRANSACTION to make these changes temporary <EFBFBD>
|
||||
--+-----------------------------------------------------------------+
|
||||
BEGIN TRANSACTION
|
||||
|
||||
DECLARE @Children AS TABLE
|
||||
(
|
||||
ItemID INT PRIMARY KEY,
|
||||
NewItemID INT,
|
||||
ContentID INT,
|
||||
NewContentID INT,
|
||||
FormatID INT,
|
||||
NewFormatID INT
|
||||
)
|
||||
DECLARE @NewDocuments AS TABLE
|
||||
(
|
||||
DocID INT PRIMARY KEY,
|
||||
NewDocID INT
|
||||
)
|
||||
-- Locals
|
||||
DECLARE @DTS DATETIME -- DTS of all New Items
|
||||
SET @DTS = GETDATE() -- Get the current Date and Time
|
||||
-- Get a list of all of the Items to be copied based upon StartItemID and EndItemID
|
||||
-- If the StartItemID = EndItemID then it is a single item and it's children
|
||||
INSERT INTO @Children SELECT ItemID,ItemID,ContentID,ContentID,FormatID,FormatID FROM vefn_ChildItemsRange(@StartItemID,@StartItemID,null)
|
||||
-- <<< Copy Contents >>>
|
||||
-- Create new content rows to match the existing rows. Set the type to the Current ContentID temporarily
|
||||
-- so that the new content rows can be associated with the existing content rows.
|
||||
INSERT INTO Contents
|
||||
([Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID])
|
||||
select [Number],[Text],[ContentID],[FormatID],[Config],@DTS,@UserID
|
||||
from Contents where ContentID in(Select ContentID from @Children)
|
||||
-- Update the @Children with the NewConentIDs
|
||||
UPDATE NN set NN.NewContentID = CC.ContentID
|
||||
From Contents CC
|
||||
Join @Children NN on NN.ContentID = CC.Type AND CC.DTS = @DTS and CC.UserID = @UserID
|
||||
-- Reset the Type column in the Contents table with the Type column from the original Records.
|
||||
UPDATE CC set CC.Type = CC2.Type
|
||||
From Contents CC
|
||||
Join @Children NN on NN.NewContentID = CC.ContentID
|
||||
Join Contents CC2 on NN.ContentID = CC2.ContentID
|
||||
-- Contents are done
|
||||
-- SELECT * From Contents where DTS = @DTS and UserID = @UserID
|
||||
-- <<< Copy Items >>>
|
||||
-- Create new item rows based upon the current item rows and the @Children table, with the NewContentIDs
|
||||
INSERT INTO [Items] ([PreviousID],[ContentID],[DTS],[UserID])
|
||||
SELECT II.[PreviousID], -- Leave the PreviousID as is for now
|
||||
NN.NewContentID, @DTS, @UserID
|
||||
from @Children NN
|
||||
join Items II on II.ContentID = NN.ContentID
|
||||
-- Update the @Children with the NewItemIDs
|
||||
UPDATE NN set NN.NewItemID = II.ItemID
|
||||
From Items II
|
||||
Join @Children NN on NN.NewContentID = II.ContentID AND II.DTS = @DTS and II.UserID = @UserID
|
||||
DECLARE @NewItemID int
|
||||
SELECT @NewItemID = NewItemID
|
||||
FROM @Children
|
||||
WHERE ItemID = @StartItemID
|
||||
UPDATE NN SET NN.[NewFormatID] = CC.[FormatID]
|
||||
FROM @Children NN
|
||||
Join vefn_ChildItemsRange(@NewItemID,@NewItemID,@DestFormatID) CC
|
||||
ON NN.NewItemID = CC.ItemID
|
||||
-- The @Children table is now complete
|
||||
--SELECT * From @Children
|
||||
-- Update the PreviousID in the new Item rows, to the new ItemIDs based upon the old ItemIDs
|
||||
Update II Set II.[PreviousID] = NN.NewItemID
|
||||
from Items II
|
||||
Join @Children NN on NN.ItemID = II.PreviousID AND II.DTS = @DTS and II.UserID = @UserID
|
||||
-- Get the new ItemIDs based upon the old ItemIDs
|
||||
SELECT @NewStartItemID = NewItemID from @Children where ItemID = @StartItemID
|
||||
--SELECT @NewEndItemID = NewItemID from @Children where ItemID = @EndItemID
|
||||
-- Set the PreviousID for the starting Item to null temporarily.
|
||||
-- This will be adjusted based upon where the step is inserted.
|
||||
Update Items Set PreviousID = null where ItemID = @NewStartItemID
|
||||
-- Items are done
|
||||
--SELECT * From Items where DTS = @DTS and UserID = @UserID
|
||||
-- <<< Copy Parts >>>
|
||||
INSERT INTO [Parts] ([ContentID],[FromType],[ItemID],[DTS],[UserID])
|
||||
Select NNF.NewContentID,[FromType],NNT.NewItemID, @DTS, @UserID from Parts PP
|
||||
JOIN @Children NNF on PP.ContentID = NNF.ContentID
|
||||
JOIN @Children NNT on PP.ItemID = NNT.ItemID
|
||||
-- Parts are done
|
||||
-- SELECT * From Parts where DTS = @DTS and UserID = @UserID
|
||||
-- <<< Copy Annotations >>>
|
||||
INSERT INTO [Annotations] ([ItemID],[TypeID],[RtfText],[SearchText],[Config],[DTS],[UserID])
|
||||
Select NewItemID, TypeID, RtfText, SearchText, Config, @DTS, @UserID
|
||||
from Annotations AA Join @Children NN on AA.ItemID = NN.ItemID
|
||||
-- Annotations are done
|
||||
-- SELECT * From Annotations where DTS = @DTS and UserID = @UserID
|
||||
-- <<< Copy Documents and Entries>>>
|
||||
-- logic to create Entries for Library Documents
|
||||
INSERT INTO [Entries] ([ContentID],[DocID],[DTS],[UserID])
|
||||
SELECT NN.[NewContentID],EE.[DocID],@DTS,@UserID
|
||||
FROM [Entries] EE JOIN @Children NN on NN.ContentID = EE.ContentID
|
||||
JOIN [Documents] DD on EE.[DocID] = DD.[DocID] and Isnull(LibTitle,'') <> ''
|
||||
-- Logic to create new documents for any documents used that do not have libtitles
|
||||
INSERT INTO [Documents] ([LibTitle],[DocContent],[DocAscii],[Config],[DTS],[UserID],[FileExtension],[DocPdf])
|
||||
OUTPUT CAST(INSERTED.[LibTitle] as INT),INSERTED.[DocID] INTO @NewDocuments
|
||||
SELECT str(DD.[DocID]),[DocContent],[DocAscii],[Config],@DTS,@UserID,[FileExtension],[DocPdf]
|
||||
FROM [Entries] EE JOIN @Children NN on NN.ContentID = EE.ContentID
|
||||
JOIN [Documents] DD on EE.[DocID] = DD.[DocID] and Isnull(LibTitle,'') = ''
|
||||
UPDATE DD SET LibTitle = ''
|
||||
FROM Documents DD JOIN @NewDocuments ND on DD.[DocID] = ND.[NewDocID]
|
||||
where DTS = @DTS and UserID = @UserID
|
||||
-- Documents are Done
|
||||
-- SELECT * From Documents where DTS = @DTS and UserID = @UserID
|
||||
-- Logic to create entries for these newly created documents
|
||||
INSERT INTO [Entries] ([ContentID],[DocID],[DTS],[UserID])
|
||||
SELECT NN.[NewContentID],ND.[NewDocID],@DTS,@UserID
|
||||
FROM [Entries] EE JOIN @Children NN on NN.ContentID = EE.ContentID
|
||||
JOIN @NewDocuments ND on EE.[DocID] = ND.[DocID]
|
||||
-- Entries are done
|
||||
-- SELECT * From Entries EE JOIN Documents DD on ee.DocID = DD.DocID where EE.DTS = @DTS and EE.UserID = @UserID
|
||||
-- <<< Copy RoUsages >>>
|
||||
INSERT INTO [VEPROMS].[dbo].[RoUsages] ([ContentID],[ROID],[Config],[DTS],[UserID],[RODbID])
|
||||
SELECT NN.[NewContentID],CAST([ROUsageID] as nvarchar(16)),[Config],@DTS,@UserID,[RODbID]
|
||||
FROM [RoUsages] RR Join @Children NN on RR.ContentID = NN.ContentID
|
||||
-- Update content records for newly copied records to use correct RO usage ids in the RO tags
|
||||
DECLARE @RowsAffected int
|
||||
SET @RowsAffected=1
|
||||
WHILE @RowsAffected > 0
|
||||
BEGIN
|
||||
UPDATE CC SET [TEXT] = C2.NewText
|
||||
FROM CONTENTS CC
|
||||
JOIN (SELECT C1.ContentID, .dbo.vefn_FixROText(C1.Text, CAST([ROID] as int), [ROUsageID]) NewText
|
||||
FROM CONTENTS C1
|
||||
JOIN @Children NN on C1.ContentID = NN.NewContentID
|
||||
JOIN RoUsages RO on NN.NewContentID = RO.ContentID) C2 ON CC.ContentID = C2.ContentID
|
||||
WHERE [TEXT] <> C2.NewText
|
||||
SET @RowsAffected = @@RowCount
|
||||
END
|
||||
UPDATE RON SET [ROID] = ROO.[ROID]
|
||||
FROM RoUsages RON
|
||||
JOIN @Children NN on RON.ContentID = NN.NewContentID
|
||||
JOIN RoUsages ROO on CAST(RON.ROID as int) = ROO.RoUsageID
|
||||
|
||||
-- RoUsages are done
|
||||
-- SELECT * From RoUsages where DTS = @DTS and UserID = @UserID
|
||||
|
||||
-- <<< Copy Transtions >>>
|
||||
-- Note that the inserted record has the 'TranType' field set to old transitionid. This is done
|
||||
-- so that the next step can replace the old transitionid with the new transitionid in the
|
||||
-- content record's transition tokens. The TranType gets reset after the content records are
|
||||
-- updated.
|
||||
-- Also note that the 'toid/rangeid' may need converted to newly copied ids or may not. If it's
|
||||
-- not a range, then it always is converted to new, if there is a new. If it's a range, both
|
||||
-- the toid & the rangeid must be new in order for the conversion to be correct. You cannot
|
||||
-- have part of the range pointing to the new and part of the range pointing to the original
|
||||
-- locations.
|
||||
|
||||
INSERT INTO .[dbo].[Transitions] ([FromID],[ToID],[RangeID],[TranType],[Config],[DTS],[UserID])
|
||||
SELECT NNF.[NewContentID],
|
||||
-- if both toid & range are null, use the original toid & rangeid
|
||||
CASE WHEN NNT.[NewItemID] is null or NNR.[NewItemID] is null THEN [ToID] ELSE NNT.[NewItemID] END,
|
||||
CASE WHEN NNT.[NewItemID] is null or NNR.[NewItemID] is null THEN [RangeID] ELSE NNR.[NewItemID] END,
|
||||
[TransitionID],[Config],@DTS,@UserID
|
||||
FROM .[dbo].[Transitions] TT
|
||||
JOIN @Children NNF on TT.[FromID] = NNF.[ContentID]
|
||||
LEFT JOIN @Children NNT on TT.[ToID] = NNT.[ItemID]
|
||||
LEFT JOIN @Children NNR on TT.[RangeID] = NNR.[ItemID]
|
||||
-- -- Update content records for newly copied records to use correct TransitionIDs in the Transition tags
|
||||
SET @RowsAffected=1
|
||||
WHILE @RowsAffected > 0
|
||||
BEGIN
|
||||
UPDATE CC SET [TEXT] = C2.NewText
|
||||
FROM CONTENTS CC
|
||||
JOIN (SELECT C1.ContentID, .dbo.vefn_FixTransitionTextForCopy(C1.Text, TRO.TransitionID, TRO.TranType, TRO.[ToID], TRO.[RangeID],TR.[TransitionID], TR.[ToID], TR.[RangeID], .dbo.vefn_GetNewTranType(NN.FormatID, NN.NewFormatID, TRO.TranType)) NewText
|
||||
FROM CONTENTS C1
|
||||
JOIN @Children NN on C1.ContentID = NN.NewContentID
|
||||
JOIN Transitions TR on NN.NewContentID = TR.FromID
|
||||
JOIN Transitions TRO on TR.TranType = TRO.TransitionID) C2 ON CC.ContentID = C2.ContentID
|
||||
WHERE [TEXT] <> C2.NewText
|
||||
SET @RowsAffected = @@RowCount
|
||||
END
|
||||
-- Add 'Verification Required' AnnotationType
|
||||
DECLARE @typeID int
|
||||
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
|
||||
IF(@typeID IS NULL)
|
||||
BEGIN
|
||||
INSERT INTO [AnnotationTypes] ([Name],[UserID]) VALUES ('Verification Required','Volian')
|
||||
SELECT @typeID = SCOPE_IDENTITY()
|
||||
END
|
||||
-- Add "Verification Required" Annotation for each Transition whose transition format changes
|
||||
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
|
||||
SELECT NN.NewItemID, @typeID,'Verify Transition Format',@UserID
|
||||
FROM Transitions TR
|
||||
JOIN @Children NN on TR.FromID = NN.NewContentID
|
||||
JOIN Transitions TRO on TR.TranType = TRO.TransitionID
|
||||
WHERE .dbo.vefn_CompareTranFormat(NN.FormatID, NN.NewFormatID, TRO.TranType) <> 0
|
||||
UPDATE TR SET TR.[TranType] = .dbo.vefn_GetNewTranType(NN.FormatID, NN.NewFormatID, TRO.TranType)
|
||||
FROM Transitions TR
|
||||
JOIN @Children NN on TR.FromID = NN.NewContentID
|
||||
JOIN Transitions TRO on TR.TranType = TRO.TransitionID
|
||||
-- Transitions are done
|
||||
-- SELECT * From Transitions where DTS = @DTS and UserID = @UserID
|
||||
|
||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||
END TRY
|
||||
BEGIN CATCH -- Catch Block
|
||||
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
|
||||
--USE MASTER
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: CopyItemAndChildren Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: CopyItemAndChildren Error on Creation'
|
||||
GO
|
3
PROMS/SQL/ROAfterDash.sql
Normal file
3
PROMS/SQL/ROAfterDash.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select dbo.ve_getshortpathfromcontentid(contentid) location, text, patindex('%<START%link:reference%', text), charindex('\u8209?', text)
|
||||
from contents
|
||||
where patindex('%<START%link:reference%', text) > charindex('\u8209? ', text) and charindex('\u8209? ', text) > 0
|
11
PROMS/SQL/ROAfterDash2.sql
Normal file
11
PROMS/SQL/ROAfterDash2.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
select tst, count(*) howmany from (
|
||||
select contentid, text, case when patindex('%<START%link:reference%', text) > charindex('\u8209?', text) then 'TRUE' else 'FALSE' end tst
|
||||
from contents
|
||||
where text like '%link:reference%' and text like '%\u8209?%') t1 --where tst = 'TRUE'
|
||||
group by tst
|
||||
|
||||
select * from items where itemid in (66766, 66770)
|
||||
|
||||
select dbo.ve_getshortpathfromcontentid(contentid) location, text, patindex('%<START%link:reference%', text), charindex('\u8209?', text)
|
||||
from contents
|
||||
where patindex('%<START%link:reference%', text) > charindex('\u8209?', text) and charindex('\u8209?', text) > 0
|
30
PROMS/SQL/ROImageBug/GetRODBsAndROFSTsAndAssociations.sql
Normal file
30
PROMS/SQL/ROImageBug/GetRODBsAndROFSTsAndAssociations.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- RODBs
|
||||
SELECT RODBID, ROName, FolderPath From RODBS
|
||||
-- ROFSTs
|
||||
Select ROFSTID, RODBID, DTS, len(ROLookup) Size, len(ROLookup)/1024 KBS from ROFSTS
|
||||
-- Associations
|
||||
Select AA.ROFSTID, RF.RODBID, DV.VersionID, FF.Name
|
||||
from associations AA
|
||||
Join ROFSTS RF ON AA.ROFSTID = RF.ROFSTID
|
||||
Join DocVersions DV ON DV.VersionID = AA.VersionID
|
||||
Join Folders FF ON Dv.FolderID = FF.FolderID
|
||||
--
|
||||
select RODBID,Count(*) HowMany from ROUSages Group by RODBID
|
||||
select RODBID,Count(*) HowMany from DROUSages Group by RODBID
|
||||
select ImageID, RODBID,FileName from ROIMAGES
|
||||
select FF.ImageID, RODBID from Figures FF Join ROImages RI ON RI.ImageID = FF.ImageID
|
||||
/*
|
||||
--Update RODBs Set FolderPath = 'C:\Plant\VEHLP\RO' where RODBID = 1
|
||||
Update Associations Set ROFSTID = 4
|
||||
delete from Figures where ROFSTID != 4
|
||||
DELETE From ROFSTS where ROFSTID != 4
|
||||
update roFSTs set RODBID = 1
|
||||
Update ROUSages set RODBID =1 where RODBID=2
|
||||
Update Contents Set Text = Replace(TEXT,' 2[END>',' 1[END>') where Text like '% 2\[END>%' escape '\'
|
||||
Update DROUSages set RODBID =1 where RODBID=2
|
||||
Update ROImages set RODBID=1 where RODBID=2 and FileName Not In (Select FileName from roimages where RODBID=1)
|
||||
Update FF Set FF.ImageID = (select ImageID from ROImages RI1 where RI1.RODBID=1 and RI.FileName = RI1.FileName)
|
||||
from Figures FF join ROIMages RI ON FF.ImageID = RI.ImageID Where RODBID = 2
|
||||
DELETE ROImages where RODBID=2
|
||||
Delete RODBs Where RODBID = 2
|
||||
*/
|
1
PROMS/SQL/ROImageBug/ROFstsSize.sql
Normal file
1
PROMS/SQL/ROImageBug/ROFstsSize.sql
Normal file
@@ -0,0 +1 @@
|
||||
select ROFSTID,RODBID,Len(ROLOOKUP) MyLength, DTS,UserID from ROFSTS
|
81
PROMS/SQL/ROImageBug/ROValues.sql
Normal file
81
PROMS/SQL/ROImageBug/ROValues.sql
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
DECLARE @TEXT nvarchar(max)
|
||||
select @TEXT = TEXT from Contents where ContentID Like 17259
|
||||
select * from vefn_SplitROs(@TEXT)
|
||||
--\v <START]\v0 11%\v #Link:ReferencedObject:2933 0003000000940000 2[END>\v0
|
||||
|
||||
SELECT ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID, RO.RODBID FROM CONTENTS
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
|
||||
SELECT ContentID --, RO.Value, RO.UsageID, RO.ROID
|
||||
FROM CONTENTS
|
||||
--CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
|
||||
|
||||
SELECT ContentID, RO.Value, RO.UsageID, RO.ROID FROM CONTENTS
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where CONTENTID = 708
|
||||
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[vefn_SplitROs](@text varchar(MAX))
|
||||
RETURNS @ROValues TABLE
|
||||
(
|
||||
Value varchar(max),
|
||||
UsageID int,
|
||||
ROID varchar(20),
|
||||
RODBID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @START nvarchar(255)
|
||||
SET @START= '\v <START]\v0 '
|
||||
DECLARE @MIDDLE nvarchar(255)
|
||||
SET @MIDDLE = '\v #Link:'
|
||||
DECLARE @MIDDLERO nvarchar(255)
|
||||
SET @MIDDLERO = '\v #Link:ReferencedObject:'
|
||||
DECLARE @END nvarchar(255)
|
||||
SET @END = '[END>\'
|
||||
DECLARE @IndexStart int
|
||||
SET @IndexStart = CHARINDEX(@START , @text)
|
||||
DECLARE @IndexEnd int
|
||||
SET @IndexEnd = CHARINDEX(@END , @text)
|
||||
WHILE (@IndexStart > 0)
|
||||
BEGIN
|
||||
DECLARE @PARTS NVARCHAR(MAX)
|
||||
DECLARE @PART1 NVARCHAR(MAX)
|
||||
DECLARE @PART2 NVARCHAR(MAX)
|
||||
DECLARE @PART3 NVARCHAR(MAX)
|
||||
SET @IndexStart = @IndexStart + len(@START) + 1
|
||||
--PRINT @IndexStart
|
||||
--PRINT @IndexEnd
|
||||
SET @PARTS = SUBSTRING(@TEXT,@IndexStart,@IndexEnd - @IndexStart)
|
||||
--PRINT @PARTS
|
||||
DECLARE @IndexMiddle int
|
||||
SET @IndexMiddle = CHARINDEX(@Middle , @PARTS)
|
||||
SET @PART1 = LEFT(@PARTS,@IndexMiddle-1)
|
||||
--PRINT @PART1
|
||||
SET @PARTS = SUBSTRING(@PARTS,@IndexMiddle, len(@PARTS))
|
||||
IF @PARTS LIKE @MIDDLERO + '%'
|
||||
BEGIN
|
||||
SET @PARTS = SUBSTRING(@PARTS,len(@MIDDLERO)+1,len(@PARTS))
|
||||
DECLARE @IndexSpace int
|
||||
SET @IndexSpace = CHARINDEX(' ',@PARTS)
|
||||
SET @PART2 = LEFT(@PARTS,@IndexSpace-1)
|
||||
--PRINT @PART2
|
||||
SET @PARTS = LTRIM(SUBSTRING(@PARTS,@IndexSpace+1,len(@PARTS)))
|
||||
SET @IndexSpace = CHARINDEX(' ',@PARTS)
|
||||
SET @PART3 = LEFT(@PARTS,@IndexSpace-1)
|
||||
--PRINT @PART3
|
||||
SET @PARTS = LTRIM(SUBSTRING(@PARTS,@IndexSpace+1,len(@PARTS)))
|
||||
--PRINT @PARTS
|
||||
Insert INTO @ROValues Values(@PART1, CAST(@PART2 AS INT), @PART3, Cast(@Parts as int))
|
||||
END
|
||||
SET @TEXT = SUBSTRING(@TEXT,@IndexEnd + LEN(@End), LEN(@TEXT))
|
||||
SET @IndexStart = CHARINDEX(@START , @text)
|
||||
SET @IndexEnd = CHARINDEX(@END , @text)
|
||||
END
|
||||
RETURN
|
||||
END
|
163
PROMS/SQL/ROImageBug/SectionStartStatus.sql
Normal file
163
PROMS/SQL/ROImageBug/SectionStartStatus.sql
Normal file
@@ -0,0 +1,163 @@
|
||||
Declare @TopSections Table
|
||||
(
|
||||
VersionID int,
|
||||
ProcID int,
|
||||
ItemID int Primary Key,
|
||||
ContentID int,
|
||||
Level int,
|
||||
FormatID int,
|
||||
Type int
|
||||
);
|
||||
with Itemz([VersionID], ProcID, [ItemID], [ContentID], [Level]) as
|
||||
(Select DV.VersionID, DV.ItemID ProcID, [I].[ItemID], [I].[ContentID], 0
|
||||
FROM [Items] I
|
||||
JOIN vefn_DocVersionSplit('') DV ON I.[ItemID] = DV.[ItemID]
|
||||
Union All
|
||||
-- Children
|
||||
select Z.VersionID, Z.ProcID, I.[ItemID], I.[ContentID], Z.Level+1
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
join Contents C ON I.ContentID = C.contentID
|
||||
Where Type < 20000
|
||||
Union All
|
||||
-- Siblings
|
||||
select Z.VersionID, case when z.ProcID = z.ItemID then I.ItemID else Z.ProcID end ProcID, I.[ItemID], I.[ContentID], Z.Level
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
)
|
||||
insert into @TopSections
|
||||
select ZZ.VersionID, ZZ.ProcID, ZZ.[ItemID], ZZ.[ContentID], ZZ.[Level], VI.[FormatID], CC.Type
|
||||
from ItemZ ZZ
|
||||
Join vefn_GetVersionFormatItems('') VI ON ZZ.ItemID=VI.ItemID
|
||||
Join Contents CC ON ZZ.ContentID=CC.ContentID
|
||||
Where Level > 0
|
||||
OPTION (MAXRECURSION 10000)
|
||||
|
||||
DECLARE @Procedures TABLE (
|
||||
VersionID int,
|
||||
ProcID int primary key,
|
||||
PContentID int ,
|
||||
SectionStart int
|
||||
)
|
||||
Insert into @Procedures
|
||||
Select VersionID, ItemId, ContentID, xProcedure.value('@SectionStart','int') SectionStart From
|
||||
(Select VI.VersionID,VI.ItemID,VI.ContentID,Cast(Config as xml) xConfig
|
||||
from VEFN_GetVersionItems('') VI
|
||||
Join Contents CC ON CC.ContentID = VI.ContentID
|
||||
where type = 0) T1
|
||||
outer apply xConfig.nodes('//Procedure') tProcedure(xProcedure)
|
||||
|
||||
DECLARE @SectionFormats TABLE
|
||||
(
|
||||
FormatID int,
|
||||
Name nvarchar(50),
|
||||
Description nvarchar(255),
|
||||
Type int,
|
||||
IsStepSection nvarchar(10),
|
||||
SectionFormat nvarchar(255),
|
||||
NumberingSequence int
|
||||
)
|
||||
Insert Into @SectionFormats
|
||||
Select FormatID, Name, Description
|
||||
,xDocStyle.value('@Index','int')+10000 Type
|
||||
,xDocStyle.value('@IsStepSection','nvarchar(10)') IsStepSection
|
||||
,xDocStyle.value('@Name','nvarchar(255)') SectionFormat
|
||||
,xDocStyle.value('@NumberingSequence','int') NumberingSequence
|
||||
from Formats
|
||||
outer apply data.nodes('//DocStyle') tDocStyle(xDocStyle)
|
||||
where FormatID in(Select formatid from @TopSections)
|
||||
|
||||
DECLARE @OriginalSteps Table
|
||||
(
|
||||
VersionID int,
|
||||
ProcID int,
|
||||
ItemID int,
|
||||
ContentID int,
|
||||
Level int,
|
||||
FormatID int,
|
||||
Type int
|
||||
-- ,OriginalSteps char(1)
|
||||
)
|
||||
Insert Into @OriginalSteps
|
||||
Select VersionID, ProcID, ItemID, ContentID, Level, FormatID,Type
|
||||
--,isnull(xSection.value('@OriginalSteps','char(1)'),'N') OriginalSteps
|
||||
From
|
||||
(Select TS.*, cast(config as xml) xConfig From @TopSections TS
|
||||
Join Contents CC ON TS.ContentID=CC.ContentID) T1
|
||||
Outer apply xConfig.nodes('//Section') tSection(xSection)
|
||||
where isnull(xSection.value('@OriginalSteps','char(1)'),'N') ='Y'
|
||||
|
||||
--Select * from @OriginalSteps
|
||||
Declare @MultipleOriginalSteps TABLE
|
||||
(
|
||||
ProcID int primary Key,
|
||||
HowMany int
|
||||
)
|
||||
insert into @MultipleOriginalSteps
|
||||
select ProcID, Count(*) Howmany from @OriginalSteps Group by ProcID Having count(*) > 1
|
||||
|
||||
|
||||
select SectionStartStatus, OriginalStepStatus, Count(*) Howmany from (
|
||||
Select PP.*, dbo.ve_getShortPath(SectionStart) PathToSectionStart, SSTS.ItemID, SSTS.FormatID, SSSF.IsStepSection, SSTS.Level
|
||||
, isnull(OSExact.ItemID,OS.ItemID) OSItemID, MOS.ProcID MProcId,ossf.IsStepSection OSIsStepSection
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When SSTS.ItemID is null THEN 'NotSection'
|
||||
When SSTS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When SSTS.Level > 1 then 'NotTopLevel'
|
||||
When SSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end SectionStartStatus
|
||||
,case when isnull(OSExact.ItemID,OS.ItemID) is null then 'None'
|
||||
when MOS.ProcID is not null THEN 'MultipleOS'
|
||||
When OSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end OriginalStepStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections SSTS ON PP.SectionStart = SSTS.ItemID
|
||||
Left Join @SectionFormats SSSF ON SSTS.FormatID= SSSF.FormatID and SSTS.Type=SSSF.Type
|
||||
Left Join @MultipleOriginalSteps MOS ON pp.ProcID = MOS.ProcID
|
||||
Left Join @OriginalSteps OSExact ON OSExact.ProcID=pp.ProcID and OSExact.ItemID=pp.SectionStart
|
||||
Left Join (select * from @OriginalSteps Where ProcID Not In (Select Procid from @MultipleOriginalSteps)) OS ON OS.ProcID = pp.procid
|
||||
Left Join @SectionFormats OSSF ON isnull(OSExact.FormatID,OS.FormatID)= OSSF.FormatID and isnull(OSExact.Type,OS.Type)=OSSF.Type
|
||||
) T1 Group by SectionStartStatus, OriginalStepStatus
|
||||
|
||||
|
||||
Select PP.*, dbo.ve_getShortPath(SectionStart) PathToSectionStart, SSTS.ItemID, SSTS.FormatID, SSSF.IsStepSection, SSTS.Level
|
||||
, isnull(OSExact.ItemID,OS.ItemID) OSItemID, MOS.ProcID MProcId,ossf.IsStepSection OSIsStepSection
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When SSTS.ItemID is null THEN 'NotSection'
|
||||
When SSTS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When SSTS.Level > 1 then 'NotTopLevel'
|
||||
When SSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end SectionStartStatus
|
||||
,case when isnull(OSExact.ItemID,OS.ItemID) is null then 'None'
|
||||
when MOS.ProcID is not null THEN 'MultipleOS'
|
||||
When OSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end OriginalStepStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections SSTS ON PP.SectionStart = SSTS.ItemID
|
||||
Left Join @SectionFormats SSSF ON SSTS.FormatID= SSSF.FormatID and SSTS.Type=SSSF.Type
|
||||
Left Join @MultipleOriginalSteps MOS ON pp.ProcID = MOS.ProcID
|
||||
Left Join @OriginalSteps OSExact ON OSExact.ProcID=pp.ProcID and OSExact.ItemID=pp.SectionStart
|
||||
Left Join (select * from @OriginalSteps Where ProcID Not In (Select Procid from @MultipleOriginalSteps)) OS ON OS.ProcID = pp.procid
|
||||
Left Join @SectionFormats OSSF ON isnull(OSExact.FormatID,OS.FormatID)= OSSF.FormatID and isnull(OSExact.Type,OS.Type)=OSSF.Type
|
||||
|
||||
|
||||
/*
|
||||
Select VersionID,GrandParentName,ParentName,FolderName,[Good],[None],[NotInProc],[NotSection],[NotTopLevel]
|
||||
FROM (Select VN.*, PP.ProcID
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When TS.ItemID is null THEN 'NotSection'
|
||||
When TS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When Level > 1 then 'NotTopLevel'
|
||||
else 'Good' end SectionStartStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections TS ON PP.SectionStart = TS.ItemID
|
||||
Join VEFN_GetVersionNames() VN ON VN.VersionID = PP.VersionID) P1
|
||||
PIVOT(COUNT(ProcID) FOR SectionStartStatus IN ( [Good],[None],[NotInProc],[NotSection],[NotTopLevel]))
|
||||
AS P2
|
||||
Order By VersionID
|
||||
*/
|
7
PROMS/SQL/ROImageBug/VersionAssocaitions.sql
Normal file
7
PROMS/SQL/ROImageBug/VersionAssocaitions.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
SELECT DV.VersionID, FF.NAme, ASSOCIATIONID, AA.ROFSTID, RODBID
|
||||
from DocVersions DV
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
|
||||
Update Associations set ROFSTID = 4 where AssociationID = 3
|
18
PROMS/SQL/ROImageBug/VersionRODBIDsDetail.sql
Normal file
18
PROMS/SQL/ROImageBug/VersionRODBIDsDetail.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
SELECT VI.VersionID,
|
||||
FF.Name, RF.RODBID VersionDBID
|
||||
, .dbo.ve_GetShortPathFromContentID(CC.ContentID) Location
|
||||
, CC.ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID
|
||||
, RO.RODBID TextRODBID, RD.RONAME
|
||||
--, Count(*) HowMany
|
||||
FROM CONTENTS CC
|
||||
JOIN vefn_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN DocVersions DV ON DV.VersionID = VI.VersionID
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
JOIN RODBS RD ON RD.RODBID = RF.RODBID
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
--Group By
|
||||
--VI.VersionID,
|
||||
--FF.Name, RF.RODBID , RO.RODBID, RD.ROName
|
18
PROMS/SQL/ROImageBug/VersionRODBIDsSummary.sql
Normal file
18
PROMS/SQL/ROImageBug/VersionRODBIDsSummary.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
SELECT --VI.VersionID,
|
||||
FF.Name, RF.RODBID VersionDBID
|
||||
--, .dbo.ve_GetShortPathFromContentID(CC.ContentID) Location
|
||||
--, CC.ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID
|
||||
, RO.RODBID TextRODBID, RD.RONAME
|
||||
, Count(*) HowMany
|
||||
FROM CONTENTS CC
|
||||
JOIN vefn_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN DocVersions DV ON DV.VersionID = VI.VersionID
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
JOIN RODBS RD ON RD.RODBID = RF.RODBID
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
Group By
|
||||
--VI.VersionID,
|
||||
FF.Name, RF.RODBID , RO.RODBID, RD.ROName
|
7
PROMS/SQL/RemoveFullTextSearch.sql
Normal file
7
PROMS/SQL/RemoveFullTextSearch.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
DROP FULLTEXT INDEX ON CONTENTS
|
||||
go
|
||||
DROP FULLTEXT INDEX ON DOCUMENTS
|
||||
go
|
||||
DROP FULLTEXT CATALOG FT_Catalog
|
||||
go
|
||||
EXEC sp_fulltext_database 'disable'
|
21
PROMS/SQL/ReplaceWords.sql
Normal file
21
PROMS/SQL/ReplaceWords.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
use veproms
|
||||
select dbo.ve_GetShortPath(II.ItemID) Path,Text, Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Text,'\ul OR\ulnone ','OR'),'\ul NOT\ulnone ','NOT'),'\ul THEN\ulnone ','THEN'),'\ul IF\ulnone ','IF'),'\ul AND\ulnone ','AND'),'\ul NOT\ul0 ','NOT'),'\ul THEN\ul0 ','THEN'),'\ul AND\ul0 ','AND'),'\ul WHEN\ul0 ','WHEN'),'\ul OR\ul0 ','OR'),'\ul IF\ul0 ','IF')
|
||||
from items ii
|
||||
join contents cc on ii.ContentID = cc.ContentID
|
||||
--where ItemID = 101
|
||||
where text like '%\ul%'
|
||||
use master
|
||||
|
||||
use veproms
|
||||
Update Contents
|
||||
Set Text = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Text,'\ul OR\ulnone ','OR'),'\ul NOT\ulnone ','NOT'),'\ul THEN\ulnone ','THEN'),'\ul IF\ulnone ','IF'),'\ul AND\ulnone ','AND'),'\ul NOT\ul0 ','NOT'),'\ul THEN\ul0 ','THEN'),'\ul AND\ul0 ','AND'),'\ul WHEN\ul0 ','WHEN'),'\ul OR\ul0 ','OR'),'\ul IF\ul0 ','IF')
|
||||
where text like '%\ul%'
|
||||
Update Contents Set Text = Replace(Text,'GO TO','go to') where Text like '%GO TO%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
Update Contents Set Text = Replace(Text,'RETURN TO','return to') where Text like '%RETURN TO%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
Update Contents Set Text = Replace(Text,'REFER TO','refer to') where Text like '%REFER TO%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
Update Contents Set Text = Replace(Text,'SHALL','shall') where Text like '%SHALL%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
Update Contents Set Text = Replace(Text,'GREATER THAN OR EQUAL TO','greater than or equal to') where Text like '%GREATER THAN OR EQUAL TO%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
Update Contents Set Text = Replace(Text,'LESS THAN OR EQUAL TO','less than or equal to') where Text like '%LESS THAN OR EQUAL TO%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
Update Contents Set Text = Replace(Text,'GREATER THAN','greater than') where Text like '%GREATER THAN%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
Update Contents Set Text = Replace(Text,'LESS THAN','less than') where Text like '%LESS THAN%' Collate SQL_Latin1_General_CP1_CS_AS
|
||||
use master
|
2
PROMS/SQL/RestoreFullTextIndex.sql
Normal file
2
PROMS/SQL/RestoreFullTextIndex.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER FULLTEXT INDEX ON Contents START FULL POPULATION
|
||||
ALTER FULLTEXT INDEX ON Documents START FULL POPULATION
|
144
PROMS/SQL/RevisionTables.sql
Normal file
144
PROMS/SQL/RevisionTables.sql
Normal file
@@ -0,0 +1,144 @@
|
||||
drop table revisionchecks
|
||||
go
|
||||
drop table revisionpdfs
|
||||
go
|
||||
drop table revisions
|
||||
go
|
||||
drop table revisionstages
|
||||
go
|
||||
drop table revisiontypes
|
||||
go
|
||||
|
||||
/****** Object: Table [dbo].[RevisionTypes] Script Date: 08/30/2011 14:30:25 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionTypes](
|
||||
[TypeID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](50) NOT NULL,
|
||||
[Description] [nvarchar](200) NULL,
|
||||
CONSTRAINT [PK_RevisionTypes] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[TypeID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
insert into revisiontypes (name) values ('Revision')
|
||||
insert into revisiontypes (name) values ('Temp Mod')
|
||||
go
|
||||
|
||||
/****** Object: Table [dbo].[RevisionStages] Script Date: 08/30/2011 14:29:16 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionStages](
|
||||
[StageID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](50) NOT NULL,
|
||||
[Description] [nvarchar](200) NULL,
|
||||
CONSTRAINT [PK_RevisionStages] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[StageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
insert into revisionstages (name) values ('Input to review')
|
||||
insert into revisionstages (name) values ('Initial review')
|
||||
insert into revisionstages (name) values ('Final review')
|
||||
insert into revisionstages (name) values ('Verification')
|
||||
insert into revisionstages (name) values ('Validation')
|
||||
insert into revisionstages (name) values ('Issued')
|
||||
insert into revisionstages (name) values ('Published')
|
||||
insert into revisionstages (name) values ('Approved')
|
||||
go
|
||||
|
||||
/****** Object: Table [dbo].[Revisions] Script Date: 08/30/2011 14:43:14 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Revisions](
|
||||
[RevisionID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ItemID] [int] NOT NULL,
|
||||
[TypeID] [int] NOT NULL,
|
||||
[RevisionNumber] [nvarchar](50) NULL,
|
||||
[RevisionDate] [datetime] NULL,
|
||||
[Notes] [nvarchar](max) NULL,
|
||||
[Config] [xml] NULL,
|
||||
CONSTRAINT [PK_Revisions] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RevisionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
ALTER TABLE [dbo].[Revisions] WITH CHECK ADD CONSTRAINT [FK_Revisions_RevisionTypes] FOREIGN KEY([TypeID])
|
||||
REFERENCES [dbo].[RevisionTypes] ([TypeID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Revisions] CHECK CONSTRAINT [FK_Revisions_RevisionTypes]
|
||||
GO
|
||||
ALTER TABLE [dbo].[Revisions] WITH CHECK ADD CONSTRAINT [FK_Revisions_tblItems] FOREIGN KEY([ItemID])
|
||||
REFERENCES [dbo].[tblItems] ([ItemID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Revisions] CHECK CONSTRAINT [FK_Revisions_tblItems]
|
||||
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[RevisionPDFs] Script Date: 08/30/2011 14:46:48 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionPDFs](
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[StageID] [int] NOT NULL,
|
||||
[DTS] [datetime] NOT NULL,
|
||||
[UserID] [nvarchar](200) NOT NULL,
|
||||
[PDF] [varbinary](max) NULL,
|
||||
CONSTRAINT [PK_RevisionPDFs] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RevisionID] ASC,
|
||||
[StageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
SET ANSI_PADDING OFF
|
||||
GO
|
||||
ALTER TABLE [dbo].[RevisionPDFs] WITH CHECK ADD CONSTRAINT [FK_RevisionPDFs_Revisions] FOREIGN KEY([RevisionID])
|
||||
REFERENCES [dbo].[Revisions] ([RevisionID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[RevisionPDFs] CHECK CONSTRAINT [FK_RevisionPDFs_Revisions]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RevisionPDFs] WITH CHECK ADD CONSTRAINT [FK_RevisionPDFs_RevisionStages] FOREIGN KEY([StageID])
|
||||
REFERENCES [dbo].[RevisionStages] ([StageID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[RevisionPDFs] CHECK CONSTRAINT [FK_RevisionPDFs_RevisionStages]
|
||||
|
||||
GO
|
||||
/****** Object: Table [dbo].[RevisionChecks] Script Date: 08/30/2011 14:48:11 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionChecks](
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[StageID] [int] NOT NULL,
|
||||
[ConsistencyChecks] [xml] NULL,
|
||||
CONSTRAINT [PK_RevisionChecks] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RevisionID] ASC,
|
||||
[StageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
ALTER TABLE [dbo].[RevisionChecks] WITH CHECK ADD CONSTRAINT [FK_RevisionChecks_RevisionPDFs] FOREIGN KEY([RevisionID], [StageID])
|
||||
REFERENCES [dbo].[RevisionPDFs] ([RevisionID], [StageID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[RevisionChecks] CHECK CONSTRAINT [FK_RevisionChecks_RevisionPDFs]
|
||||
|
||||
GO
|
103
PROMS/SQL/RevisionTables.sql.bak
Normal file
103
PROMS/SQL/RevisionTables.sql.bak
Normal file
@@ -0,0 +1,103 @@
|
||||
drop table revisionchecks
|
||||
go
|
||||
drop table revisionpdfs
|
||||
go
|
||||
drop table revisions
|
||||
go
|
||||
drop table revisionstages
|
||||
go
|
||||
drop table revisiontypes
|
||||
go
|
||||
|
||||
/****** Object: Table [dbo].[RevisionTypes] Script Date: 08/30/2011 14:30:25 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionTypes](
|
||||
[TypeID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](50) NOT NULL,
|
||||
[Description] [nvarchar](200) NULL,
|
||||
CONSTRAINT [PK_RevisionTypes] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[TypeID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
insert into revisiontypes (name) values ('Revision')
|
||||
insert into revisiontypes (name) values ('Temp Mod')
|
||||
go
|
||||
|
||||
/****** Object: Table [dbo].[RevisionStages] Script Date: 08/30/2011 14:29:16 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionStages](
|
||||
[StageID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](50) NOT NULL,
|
||||
[Description] [nvarchar](200) NULL,
|
||||
CONSTRAINT [PK_RevisionStages] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[StageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
insert into revisionstages (name) values ('Input to review')
|
||||
insert into revisionstages (name) values ('Initial review')
|
||||
insert into revisionstages (name) values ('Final review')
|
||||
insert into revisionstages (name) values ('Verification')
|
||||
insert into revisionstages (name) values ('Validation')
|
||||
insert into revisionstages (name) values ('Issued')
|
||||
insert into revisionstages (name) values ('Published')
|
||||
insert into revisionstages (name) values ('Approved')
|
||||
go
|
||||
|
||||
/****** Object: Table [dbo].[Revisions] Script Date: 08/30/2011 14:43:14 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Revisions](
|
||||
[RevisionID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ItemID] [int] NOT NULL,
|
||||
[TypeID] [int] NOT NULL,
|
||||
[RevisionNumber] [nvarchar](50) NULL,
|
||||
[RevisionDate] [datetime] NULL,
|
||||
[Notes] [nvarchar](max) NULL,
|
||||
[Config] [xml] NULL,
|
||||
CONSTRAINT [PK_Revisions] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RevisionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
/****** Object: Table [dbo].[RevisionPDFs] Script Date: 08/30/2011 14:46:48 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionPDFs](
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[DTS] [datetime] NOT NULL,
|
||||
[UserID] [nvarchar](200) NOT NULL,
|
||||
[StageID] [int] NOT NULL,
|
||||
[PDF] [varbinary](max) NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
SET ANSI_PADDING OFF
|
||||
|
||||
/****** Object: Table [dbo].[RevisionChecks] Script Date: 08/30/2011 14:48:11 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RevisionChecks](
|
||||
[RevisionID] [int] NOT NULL,
|
||||
[ObjectValues] [xml] NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
GO
|
6
PROMS/SQL/SHEAttachNum1.sql
Normal file
6
PROMS/SQL/SHEAttachNum1.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
select dv.versionid, ff.name, .dbo.ve_getshortpathfromcontentid(cc.contentid) location
|
||||
from contents cc
|
||||
join vefn_getversionitems('') vv on vv.contentid = cc.contentid
|
||||
join docversions dv on dv.versionid = vv.versionid
|
||||
join folders ff on ff.folderid = dv.folderid
|
||||
where type = 10005
|
5
PROMS/SQL/SHE_RNOoffAERPrintProblem.sql
Normal file
5
PROMS/SQL/SHE_RNOoffAERPrintProblem.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
select dbo.ve_getshortpath(pp.itemid) location, pp.itemid from parts pp
|
||||
join items ii on ii.contentid = pp.contentid
|
||||
join parts p2 on p2.itemid = ii.itemid
|
||||
--where pp.itemid = 4986
|
||||
where pp.fromtype in (3, 4) and p2.fromtype = 5
|
BIN
PROMS/SQL/SQL from JCB 20110603_1715.7z
Normal file
BIN
PROMS/SQL/SQL from JCB 20110603_1715.7z
Normal file
Binary file not shown.
8
PROMS/SQL/SearchAllDBs.sql
Normal file
8
PROMS/SQL/SearchAllDBs.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select ''{Name}'' dbname, type, count(*) HowMany from {Name}.dbo.contents where type in (20008, 20010, 20033, 20034) group by type'
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(@CommandLine,'{Name}',Name)
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1 where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user