Commit for development environment setup
This commit is contained in:
@@ -0,0 +1 @@
|
||||
sp_changedbowner sa
|
File diff suppressed because it is too large
Load Diff
115
PROMS/VEPROMS.CSLA.Library/Sql commands/2.FullTextSetup.SQL
Normal file
115
PROMS/VEPROMS.CSLA.Library/Sql commands/2.FullTextSetup.SQL
Normal file
@@ -0,0 +1,115 @@
|
||||
|
||||
EXEC sp_fulltext_database 'enable'
|
||||
go
|
||||
IF EXISTS (select ssche.name as TABLE_OWNER, sobj.name as TABLE_NAME, sidx.name as FULLTEXT_KEY_INDEX_NAME,
|
||||
sidxcol.column_id as FULLTEXT_KEY_COLID, sftidx.is_enabled as FULLTEXT_INDEX_ACTIVE, scat.name as FULLTEXT_CATALOG_NAME
|
||||
from sys.objects as sobj
|
||||
join sys.fulltext_indexes as sftidx on (sobj.object_id = sftidx.object_id)
|
||||
join sys.indexes as sidx on(sftidx.unique_index_id = sidx.index_id and sftidx.object_id = sidx.object_id)
|
||||
join sys.schemas as ssche on (sobj.schema_id = ssche.schema_id)
|
||||
join sys.index_columns as sidxcol on (sftidx.object_id = sidxcol.object_id and sftidx.unique_index_id = sidxcol.index_id)
|
||||
left outer join sys.fulltext_catalogs as scat on (scat.fulltext_catalog_id = sftidx.fulltext_catalog_id)
|
||||
where sobj.name ='CONTENTS')
|
||||
DROP FULLTEXT INDEX ON CONTENTS
|
||||
IF EXISTS (select ssche.name as TABLE_OWNER, sobj.name as TABLE_NAME, sidx.name as FULLTEXT_KEY_INDEX_NAME,
|
||||
sidxcol.column_id as FULLTEXT_KEY_COLID, sftidx.is_enabled as FULLTEXT_INDEX_ACTIVE, scat.name as FULLTEXT_CATALOG_NAME
|
||||
from sys.objects as sobj
|
||||
join sys.fulltext_indexes as sftidx on (sobj.object_id = sftidx.object_id)
|
||||
join sys.indexes as sidx on(sftidx.unique_index_id = sidx.index_id and sftidx.object_id = sidx.object_id)
|
||||
join sys.schemas as ssche on (sobj.schema_id = ssche.schema_id)
|
||||
join sys.index_columns as sidxcol on (sftidx.object_id = sidxcol.object_id and sftidx.unique_index_id = sidxcol.index_id)
|
||||
left outer join sys.fulltext_catalogs as scat on (scat.fulltext_catalog_id = sftidx.fulltext_catalog_id)
|
||||
where sobj.name ='DOCUMENTS')
|
||||
DROP FULLTEXT INDEX ON Documents
|
||||
GO
|
||||
GO
|
||||
declare @ftc as sysname
|
||||
IF EXISTS(select name from sys.fulltext_catalogs)
|
||||
begin
|
||||
select @ftc = 'DROP FULLTEXT CATALOG ' + name from sys.fulltext_catalogs
|
||||
exec sp_sqlexec @ftc
|
||||
end
|
||||
CREATE FULLTEXT CATALOG FT_Catalog
|
||||
go
|
||||
CREATE FULLTEXT INDEX ON Contents
|
||||
(
|
||||
Text
|
||||
Language 1033
|
||||
)
|
||||
KEY INDEX PK_Contents ON FT_Catalog
|
||||
WITH CHANGE_TRACKING AUTO
|
||||
GO
|
||||
CREATE FULLTEXT INDEX ON Documents
|
||||
(
|
||||
DocAscii
|
||||
Language 1033
|
||||
)
|
||||
KEY INDEX PK_Documents ON FT_Catalog
|
||||
WITH CHANGE_TRACKING AUTO
|
||||
GO
|
||||
select case FullTextCatalogProperty('FT_Catalog', '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('FT_Catalog', 'PopulateStatus')
|
||||
/*
|
||||
SELECT * FROM contents WHERE CONTAINS(text, '"FOLLOW*"') -- 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*"'); --
|
||||
*/
|
1002
PROMS/VEPROMS.CSLA.Library/Sql commands/20090107_SQL_For_Search.sql
Normal file
1002
PROMS/VEPROMS.CSLA.Library/Sql commands/20090107_SQL_For_Search.sql
Normal file
File diff suppressed because it is too large
Load Diff
1018
PROMS/VEPROMS.CSLA.Library/Sql commands/3.SearchSetup.SQL
Normal file
1018
PROMS/VEPROMS.CSLA.Library/Sql commands/3.SearchSetup.SQL
Normal file
File diff suppressed because it is too large
Load Diff
190
PROMS/VEPROMS.CSLA.Library/Sql commands/AddROfsts_20090107.sql
Normal file
190
PROMS/VEPROMS.CSLA.Library/Sql commands/AddROfsts_20090107.sql
Normal file
@@ -0,0 +1,190 @@
|
||||
USE [VEPROMS]
|
||||
GO
|
||||
/****** Object: Table [dbo].[RODbs] Script Date: 01/07/2009 09:44:32 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RODbs](
|
||||
[RODbID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ROName] [nvarchar](255) NOT NULL,
|
||||
[FolderPath] [nvarchar](255) NOT NULL,
|
||||
[DBConnectionString] [nvarchar](max) NOT NULL,
|
||||
[Config] [nvarchar](max) NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_RODbs_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_RODbs_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_RODbs] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RODbID] 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
|
||||
CREATE UNIQUE NONCLUSTERED INDEX [IX_RODbs_FolderPath] ON [dbo].[RODbs]
|
||||
(
|
||||
[FolderPath] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Hook for future - to allow the user to select multiple RO Databases assocaiated with on DocVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RODbs', @level2type=N'COLUMN',@level2name=N'ROName'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Path to the RO database' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RODbs', @level2type=N'COLUMN',@level2name=N'FolderPath'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Connection String - Default could just be the full path and name of the database' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RODbs', @level2type=N'COLUMN',@level2name=N'DBConnectionString'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'{datetime}' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RODbs', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
/****** Object: Table [dbo].[Associations] Script Date: 01/07/2009 09:44:27 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Associations](
|
||||
[AssociationID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[VersionID] [int] NOT NULL,
|
||||
[ROFstID] [int] NOT NULL,
|
||||
[Config] [nvarchar](max) NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Associations_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Associations_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Associations_1] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[AssociationID] 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
|
||||
CREATE UNIQUE NONCLUSTERED INDEX [IX_Associations_VersionID_ROFstID] ON [dbo].[Associations]
|
||||
(
|
||||
[VersionID] ASC,
|
||||
[ROFstID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) 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'Associations', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
/****** Object: Table [dbo].[Figures] Script Date: 01/07/2009 09:44:29 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[Figures](
|
||||
[FigureID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ROFstID] [int] NOT NULL,
|
||||
[ImageID] [int] NOT NULL,
|
||||
[Config] [nvarchar](max) NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Figures_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_Figures_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_Figures_1] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[FigureID] 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
|
||||
CREATE UNIQUE NONCLUSTERED INDEX [IX_Figures_ROFstID_ImageID] ON [dbo].[Figures]
|
||||
(
|
||||
[ROFstID] ASC,
|
||||
[ImageID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) 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'Figures', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
/****** Object: Table [dbo].[ROImages] Script Date: 01/07/2009 09:44:37 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[ROImages](
|
||||
[ImageID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[RODbID] [int] NOT NULL,
|
||||
[FileName] [nvarchar](255) NOT NULL,
|
||||
[Content] [varbinary](max) NOT NULL,
|
||||
[Config] [nvarchar](max) NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_ROImages_DTS] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_ROImages_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_ROImages] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ImageID] 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'ROImages', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
/****** Object: Table [dbo].[ROFsts] Script Date: 01/07/2009 09:44:34 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[ROFsts](
|
||||
[ROFstID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[RODbID] [int] NOT NULL,
|
||||
[ROFST] [varbinary](max) NOT NULL,
|
||||
[Config] [nvarchar](max) NULL,
|
||||
[DTS] [datetime] NOT NULL CONSTRAINT [DF_Table_1_DTS1] DEFAULT (getdate()),
|
||||
[UserID] [nvarchar](100) NOT NULL CONSTRAINT [DF_ROFsts_UserID] DEFAULT (upper(suser_sname())),
|
||||
[LastChanged] [timestamp] NOT NULL,
|
||||
CONSTRAINT [PK_ROFsts] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ROFstID] 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
|
||||
CREATE UNIQUE NONCLUSTERED INDEX [IX_ROFsts] ON [dbo].[ROFsts]
|
||||
(
|
||||
[RODbID] ASC,
|
||||
[DTS] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) 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'ROFsts', @level2type=N'COLUMN',@level2name=N'DTS'
|
||||
GO
|
||||
/****** Object: ForeignKey [FK_Associations_DocVersions] Script Date: 01/07/2009 09:44:27 ******/
|
||||
ALTER TABLE [dbo].[Associations] WITH CHECK ADD CONSTRAINT [FK_Associations_DocVersions] FOREIGN KEY([VersionID])
|
||||
REFERENCES [dbo].[DocVersions] ([VersionID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Associations] CHECK CONSTRAINT [FK_Associations_DocVersions]
|
||||
GO
|
||||
/****** Object: ForeignKey [FK_Associations_ROFsts] Script Date: 01/07/2009 09:44:27 ******/
|
||||
ALTER TABLE [dbo].[Associations] WITH CHECK ADD CONSTRAINT [FK_Associations_ROFsts] FOREIGN KEY([ROFstID])
|
||||
REFERENCES [dbo].[ROFsts] ([ROFstID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Associations] CHECK CONSTRAINT [FK_Associations_ROFsts]
|
||||
GO
|
||||
/****** Object: ForeignKey [FK_Figures_ROFsts] Script Date: 01/07/2009 09:44:29 ******/
|
||||
ALTER TABLE [dbo].[Figures] WITH CHECK ADD CONSTRAINT [FK_Figures_ROFsts] FOREIGN KEY([ROFstID])
|
||||
REFERENCES [dbo].[ROFsts] ([ROFstID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Figures] CHECK CONSTRAINT [FK_Figures_ROFsts]
|
||||
GO
|
||||
/****** Object: ForeignKey [FK_Figures_ROImages] Script Date: 01/07/2009 09:44:29 ******/
|
||||
ALTER TABLE [dbo].[Figures] WITH CHECK ADD CONSTRAINT [FK_Figures_ROImages] FOREIGN KEY([ImageID])
|
||||
REFERENCES [dbo].[ROImages] ([ImageID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[Figures] CHECK CONSTRAINT [FK_Figures_ROImages]
|
||||
GO
|
||||
/****** Object: ForeignKey [FK_ROFsts_RODbs] Script Date: 01/07/2009 09:44:34 ******/
|
||||
ALTER TABLE [dbo].[ROFsts] WITH CHECK ADD CONSTRAINT [FK_ROFsts_RODbs] FOREIGN KEY([RODbID])
|
||||
REFERENCES [dbo].[RODbs] ([RODbID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[ROFsts] CHECK CONSTRAINT [FK_ROFsts_RODbs]
|
||||
GO
|
||||
/****** Object: ForeignKey [FK_Figures_RODbs] Script Date: 01/07/2009 09:44:37 ******/
|
||||
ALTER TABLE [dbo].[ROImages] WITH CHECK ADD CONSTRAINT [FK_Figures_RODbs] FOREIGN KEY([RODbID])
|
||||
REFERENCES [dbo].[RODbs] ([RODbID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[ROImages] CHECK CONSTRAINT [FK_Figures_RODbs]
|
||||
GO
|
||||
TRUNCATE TABLE ROUsages
|
||||
GO
|
||||
ALTER TABLE [dbo].[ROUsages] WITH CHECK ADD
|
||||
CONSTRAINT [FK_ROUsages_RODbs] FOREIGN KEY([RODbID])
|
||||
REFERENCES [dbo].[RODbs] ([RODbID])
|
||||
GO
|
||||
ALTER TABLE [dbo].[ROUsages] CHECK CONSTRAINT [FK_ROUsages_RODbs]
|
||||
GO
|
7753
PROMS/VEPROMS.CSLA.Library/Sql commands/CSLAProcs_20090107.sql
Normal file
7753
PROMS/VEPROMS.CSLA.Library/Sql commands/CSLAProcs_20090107.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,209 @@
|
||||
DROP PROCEDURE [addAnnotation]
|
||||
DROP PROCEDURE [addAnnotationType]
|
||||
DROP PROCEDURE [addAssignment]
|
||||
DROP PROCEDURE [addConnection]
|
||||
DROP PROCEDURE [addContent]
|
||||
DROP PROCEDURE [addDetail]
|
||||
DROP PROCEDURE [addDocument]
|
||||
DROP PROCEDURE [addDocVersion]
|
||||
DROP PROCEDURE [addEntry]
|
||||
DROP PROCEDURE [addFolder]
|
||||
DROP PROCEDURE [addFormat]
|
||||
DROP PROCEDURE [addGroup]
|
||||
DROP PROCEDURE [addItem]
|
||||
DROP PROCEDURE [addMembership]
|
||||
DROP PROCEDURE [addPart]
|
||||
DROP PROCEDURE [addPermission]
|
||||
DROP PROCEDURE [addRole]
|
||||
DROP PROCEDURE [addRoUsage]
|
||||
DROP PROCEDURE [addTransition]
|
||||
DROP PROCEDURE [addUser]
|
||||
DROP PROCEDURE [addZContent]
|
||||
DROP PROCEDURE [addZTransition]
|
||||
DROP PROCEDURE [deleteAnnotation]
|
||||
DROP PROCEDURE [deleteAnnotationType]
|
||||
DROP PROCEDURE [deleteAssignment]
|
||||
DROP PROCEDURE [deleteConnection]
|
||||
DROP PROCEDURE [deleteContent]
|
||||
DROP PROCEDURE [deleteDetail]
|
||||
DROP PROCEDURE [deleteDocument]
|
||||
DROP PROCEDURE [deleteDocVersion]
|
||||
DROP PROCEDURE [deleteEntry]
|
||||
DROP PROCEDURE [deleteFolder]
|
||||
DROP PROCEDURE [deleteFormat]
|
||||
DROP PROCEDURE [deleteGroup]
|
||||
DROP PROCEDURE [deleteItem]
|
||||
DROP PROCEDURE [deleteMembership]
|
||||
DROP PROCEDURE [deletePart]
|
||||
DROP PROCEDURE [deletePermission]
|
||||
DROP PROCEDURE [deleteRole]
|
||||
DROP PROCEDURE [deleteRoUsage]
|
||||
DROP PROCEDURE [deleteTransition]
|
||||
DROP PROCEDURE [deleteUser]
|
||||
DROP PROCEDURE [deleteZContent]
|
||||
DROP PROCEDURE [deleteZTransition]
|
||||
DROP PROCEDURE [existsAnnotation]
|
||||
DROP PROCEDURE [existsAnnotationType]
|
||||
DROP PROCEDURE [existsAssignment]
|
||||
DROP PROCEDURE [existsConnection]
|
||||
DROP PROCEDURE [existsContent]
|
||||
DROP PROCEDURE [existsDetail]
|
||||
DROP PROCEDURE [existsDocument]
|
||||
DROP PROCEDURE [existsDocVersion]
|
||||
DROP PROCEDURE [existsEntry]
|
||||
DROP PROCEDURE [existsFolder]
|
||||
DROP PROCEDURE [existsFormat]
|
||||
DROP PROCEDURE [existsGroup]
|
||||
DROP PROCEDURE [existsItem]
|
||||
DROP PROCEDURE [existsMembership]
|
||||
DROP PROCEDURE [existsPart]
|
||||
DROP PROCEDURE [existsPermission]
|
||||
DROP PROCEDURE [existsRole]
|
||||
DROP PROCEDURE [existsRoUsage]
|
||||
DROP PROCEDURE [existsTransition]
|
||||
DROP PROCEDURE [existsUser]
|
||||
DROP PROCEDURE [existsZContent]
|
||||
DROP PROCEDURE [existsZTransition]
|
||||
DROP PROCEDURE [getAnnotation]
|
||||
DROP PROCEDURE [getAnnotations]
|
||||
DROP PROCEDURE [getAnnotationsByItemID]
|
||||
DROP PROCEDURE [getAnnotationsByTypeID]
|
||||
DROP PROCEDURE [getAnnotationType]
|
||||
DROP PROCEDURE [getAnnotationTypeByName]
|
||||
DROP PROCEDURE [getAnnotationTypes]
|
||||
DROP PROCEDURE [getAssignment]
|
||||
DROP PROCEDURE [getAssignments]
|
||||
DROP PROCEDURE [getAssignmentsByFolderID]
|
||||
DROP PROCEDURE [getAssignmentsByGID]
|
||||
DROP PROCEDURE [getAssignmentsByRID]
|
||||
DROP PROCEDURE [getChildFolders]
|
||||
DROP PROCEDURE [getChildFormats]
|
||||
DROP PROCEDURE [getConnection]
|
||||
DROP PROCEDURE [getConnectionByName]
|
||||
DROP PROCEDURE [getConnections]
|
||||
DROP PROCEDURE [getContent]
|
||||
DROP PROCEDURE [getContents]
|
||||
DROP PROCEDURE [getContentsByFormatID]
|
||||
DROP PROCEDURE [getDetail]
|
||||
DROP PROCEDURE [getDetails]
|
||||
DROP PROCEDURE [getDetailsByContentID]
|
||||
DROP PROCEDURE [getDocument]
|
||||
DROP PROCEDURE [getDocuments]
|
||||
DROP PROCEDURE [getDocVersion]
|
||||
DROP PROCEDURE [getDocVersions]
|
||||
DROP PROCEDURE [getDocVersionsByFolderID]
|
||||
DROP PROCEDURE [getDocVersionsByFormatID]
|
||||
DROP PROCEDURE [getDocVersionsByItemID]
|
||||
DROP PROCEDURE [getEntries]
|
||||
DROP PROCEDURE [getEntriesByContentID]
|
||||
DROP PROCEDURE [getEntriesByDocID]
|
||||
DROP PROCEDURE [getEntry]
|
||||
DROP PROCEDURE [getFolder]
|
||||
DROP PROCEDURE [getFolderByParentID_Name]
|
||||
DROP PROCEDURE [getFolders]
|
||||
DROP PROCEDURE [getFoldersByDBID]
|
||||
DROP PROCEDURE [getFoldersByFormatID]
|
||||
DROP PROCEDURE [getFormat]
|
||||
DROP PROCEDURE [getFormatByParentID_Name]
|
||||
DROP PROCEDURE [getFormats]
|
||||
DROP PROCEDURE [getGroup]
|
||||
DROP PROCEDURE [getGroupByGroupName]
|
||||
DROP PROCEDURE [getGroups]
|
||||
DROP PROCEDURE [getItem]
|
||||
DROP PROCEDURE [getItems]
|
||||
DROP PROCEDURE [getItemsByContentID]
|
||||
DROP PROCEDURE [getLibraryDocuments]
|
||||
DROP PROCEDURE [getMembership]
|
||||
DROP PROCEDURE [getMemberships]
|
||||
DROP PROCEDURE [getMembershipsByGID]
|
||||
DROP PROCEDURE [getMembershipsByUID]
|
||||
DROP PROCEDURE [getNextItems]
|
||||
DROP PROCEDURE [getParentFolder]
|
||||
DROP PROCEDURE [getParentFormat]
|
||||
DROP PROCEDURE [getPart]
|
||||
DROP PROCEDURE [getParts]
|
||||
DROP PROCEDURE [getPartsByContentID]
|
||||
DROP PROCEDURE [getPartsByItemID]
|
||||
DROP PROCEDURE [getPermission]
|
||||
DROP PROCEDURE [getPermissions]
|
||||
DROP PROCEDURE [getPermissionsByRID]
|
||||
DROP PROCEDURE [getPreviousItem]
|
||||
DROP PROCEDURE [getRole]
|
||||
DROP PROCEDURE [getRoleByName]
|
||||
DROP PROCEDURE [getRoles]
|
||||
DROP PROCEDURE [getRoUsage]
|
||||
DROP PROCEDURE [getRoUsages]
|
||||
DROP PROCEDURE [getRoUsagesByContentID]
|
||||
DROP PROCEDURE [getTransition]
|
||||
DROP PROCEDURE [getTransitions]
|
||||
DROP PROCEDURE [getTransitionsByFromID]
|
||||
DROP PROCEDURE [getTransitionsByRangeID]
|
||||
DROP PROCEDURE [getTransitionsByToID]
|
||||
DROP PROCEDURE [getUser]
|
||||
DROP PROCEDURE [getUsers]
|
||||
DROP PROCEDURE [getZContent]
|
||||
DROP PROCEDURE [getZContents]
|
||||
DROP PROCEDURE [getZContentsByContentID]
|
||||
DROP PROCEDURE [getZTransition]
|
||||
DROP PROCEDURE [getZTransitions]
|
||||
DROP PROCEDURE [getZTransitionsByTransitionID]
|
||||
DROP PROCEDURE [purgeData]
|
||||
DROP PROCEDURE [updateAnnotation]
|
||||
DROP PROCEDURE [updateAnnotationType]
|
||||
DROP PROCEDURE [updateAssignment]
|
||||
DROP PROCEDURE [updateConnection]
|
||||
DROP PROCEDURE [updateContent]
|
||||
DROP PROCEDURE [updateDetail]
|
||||
DROP PROCEDURE [updateDocument]
|
||||
DROP PROCEDURE [updateDocVersion]
|
||||
DROP PROCEDURE [updateEntry]
|
||||
DROP PROCEDURE [updateFolder]
|
||||
DROP PROCEDURE [updateFormat]
|
||||
DROP PROCEDURE [updateGroup]
|
||||
DROP PROCEDURE [updateItem]
|
||||
DROP PROCEDURE [updateMembership]
|
||||
DROP PROCEDURE [updatePart]
|
||||
DROP PROCEDURE [updatePermission]
|
||||
DROP PROCEDURE [updateRole]
|
||||
DROP PROCEDURE [updateRoUsage]
|
||||
DROP PROCEDURE [updateTransition]
|
||||
DROP PROCEDURE [updateUser]
|
||||
DROP PROCEDURE [updateZContent]
|
||||
DROP PROCEDURE [updateZTransition]
|
||||
DROP PROCEDURE [addDocVersionROFst]
|
||||
DROP PROCEDURE [addRODb]
|
||||
DROP PROCEDURE [addROFst]
|
||||
DROP PROCEDURE [addROFstImage]
|
||||
DROP PROCEDURE [addROImage]
|
||||
DROP PROCEDURE [deleteDocVersionROFst]
|
||||
DROP PROCEDURE [deleteRODb]
|
||||
DROP PROCEDURE [deleteROFst]
|
||||
DROP PROCEDURE [deleteROFstImage]
|
||||
DROP PROCEDURE [deleteROImage]
|
||||
DROP PROCEDURE [existsDocVersionROFst]
|
||||
DROP PROCEDURE [existsRODb]
|
||||
DROP PROCEDURE [existsROFst]
|
||||
DROP PROCEDURE [existsROFstImage]
|
||||
DROP PROCEDURE [existsROImage]
|
||||
DROP PROCEDURE [getDocVersionROFst]
|
||||
DROP PROCEDURE [getDocVersionROFsts]
|
||||
DROP PROCEDURE [getDocVersionROFstsByROFstID]
|
||||
DROP PROCEDURE [getDocVersionROFstsByVersionID]
|
||||
DROP PROCEDURE [getRODb]
|
||||
DROP PROCEDURE [getRODbs]
|
||||
DROP PROCEDURE [getROFst]
|
||||
DROP PROCEDURE [getROFstImage]
|
||||
DROP PROCEDURE [getROFstImages]
|
||||
DROP PROCEDURE [getROFstImagesByImageID]
|
||||
DROP PROCEDURE [getROFstImagesByROFstID]
|
||||
DROP PROCEDURE [getROFsts]
|
||||
DROP PROCEDURE [getROFstsByRODbID]
|
||||
DROP PROCEDURE [getROImage]
|
||||
DROP PROCEDURE [getROImages]
|
||||
DROP PROCEDURE [getROImagesByRODbID]
|
||||
DROP PROCEDURE [getRoUsagesByRODbID]
|
||||
DROP PROCEDURE [updateDocVersionROFst]
|
||||
DROP PROCEDURE [updateRODb]
|
||||
DROP PROCEDURE [updateROFst]
|
||||
DROP PROCEDURE [updateROFstImage]
|
||||
DROP PROCEDURE [updateROImage]
|
BIN
PROMS/VEPROMS.CSLA.Library/Sql commands/FixSearchString.sql
Normal file
BIN
PROMS/VEPROMS.CSLA.Library/Sql commands/FixSearchString.sql
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
SELECT FormatID,20000+T.C.value('@Index','int') AS MyType
|
||||
, T.C.value('@Type','varchar(255)') AS MyType
|
||||
, T.C.value('(StepEditData/TypeMenu/@MenuItem)[1]','varchar(255)') AS MyMenuItem
|
||||
,T.C.value('@ParentType','varchar(255)') AS MyParentType
|
||||
,T.C.value('(StepEditData/@AcTable)[1]','varchar(255)') AS MyAcTable
|
||||
FROM Formats
|
||||
Cross Apply Data.nodes('/PlantFormat/FormatData/StepData/Step') T(C)
|
||||
where formatid = 79
|
@@ -0,0 +1,7 @@
|
||||
SELECT FormatID,20000+T.C.value('@Index','int') AS MyType
|
||||
, T.C.value('@Type','varchar(255)') AS MyType
|
||||
, T.C.value('(StepEditData/TypeMenu/@MenuItem)[1]','varchar(255)') AS MyMenuItem
|
||||
,T.C.value('@ParentType','varchar(255)') AS MyParentType
|
||||
FROM Formats
|
||||
Cross Apply Data.nodes('/PlantFormat/FormatData/StepData/Step') T(C)
|
||||
where formatid = 79
|
10350
PROMS/VEPROMS.CSLA.Library/Sql commands/PROMS2010.SQL
Normal file
10350
PROMS/VEPROMS.CSLA.Library/Sql commands/PROMS2010.SQL
Normal file
File diff suppressed because it is too large
Load Diff
7785
PROMS/VEPROMS.CSLA.Library/Sql commands/PROMS_CSLA_20090116.sql
Normal file
7785
PROMS/VEPROMS.CSLA.Library/Sql commands/PROMS_CSLA_20090116.sql
Normal file
File diff suppressed because it is too large
Load Diff
BIN
PROMS/VEPROMS.CSLA.Library/Sql commands/ROImages_UniqueIndex.sql
Normal file
BIN
PROMS/VEPROMS.CSLA.Library/Sql commands/ROImages_UniqueIndex.sql
Normal file
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
-- Clean-up VEPROMS before adding new ROFST Tables
|
||||
USE VEPROMS
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DocVersionROFsts]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
|
||||
Drop Table [DocVersionROFsts]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[Associations]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
|
||||
Drop Table [Associations]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ROFstImages]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
|
||||
Drop Table [ROFstImages]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[Figures]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
|
||||
Drop Table [Figures]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ROFsts]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
|
||||
Drop Table [ROFsts]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ROImages]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
|
||||
Drop Table [ROImages]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RoUsages] DROP CONSTRAINT [FK_ROUsages_RODbs] --FOREIGN KEY([RODbID]) REFERENCES [dbo].[RODbs] ([RODbID])
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[RODbs]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
|
||||
Drop Table [RODbs]
|
||||
GO
|
Binary file not shown.
@@ -0,0 +1,675 @@
|
||||
|
||||
/****** Object: StoredProcedure [getItemAndChildren] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getItemAndChildren];
|
||||
GO
|
||||
|
||||
-- getItemAndChildren 111
|
||||
CREATE PROCEDURE [dbo].[getItemAndChildren] (@ItemID int) WITH EXECUTE AS OWNER AS BEGIN
|
||||
with Itemz([Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [FromType], [ContentID], [DTS], [UserID], [LastChanged]) as (
|
||||
Select 0 [Level], 0 [ParentID], 0 [Ordinal], [ItemID], [PreviousID],0 [FromType],[ContentID],[DTS],[UserID],[LastChanged]
|
||||
FROM [Items]
|
||||
where [ItemID]=@ItemID
|
||||
Union All
|
||||
-- Children
|
||||
select [Level] + 1,Z.ItemID,0, I.[ItemID], I.[PreviousID], P.[FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
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.[ParentID],Z.[Ordinal] +1, I.[ItemID], I.[PreviousID], [FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
where Z.[Level] > 0
|
||||
)
|
||||
select I.[Level],I.[FromType],I.[Ordinal], I.[ParentID], I.[ItemID],I.[PreviousID],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged],
|
||||
C.[Number],C.[Text],C.[Type],C.[FormatID],C.[Config],C.[DTS] As [cDTS],C.[UserID] As [cUserID],C.[LastChanged] As [cLastChanged] from ItemZ I
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
order by I.[Level] , I.[FromType], I.[Ordinal]
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getItemAndChildren Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getItemAndChildren Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [getItemNextAndChildren] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getItemNextAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getItemNextAndChildren];
|
||||
GO
|
||||
|
||||
-- getItemNextAndChildren 111
|
||||
CREATE PROCEDURE [dbo].[getItemNextAndChildren] (@ItemID int) WITH EXECUTE AS OWNER AS BEGIN
|
||||
with Itemz([Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [FromType], [ContentID], [DTS], [UserID], [LastChanged]) as (
|
||||
Select 0 [Level], 0 [ParentID], 0 [Ordinal], [ItemID], [PreviousID],0 [FromType],[ContentID],[DTS],[UserID],[LastChanged]
|
||||
FROM [Items]
|
||||
where [ItemID]=@ItemID
|
||||
Union All
|
||||
-- Children
|
||||
select [Level] + 1,Z.ItemID,0, I.[ItemID], I.[PreviousID], P.[FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
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.[ParentID],Z.[Ordinal] +1, I.[ItemID], I.[PreviousID], [FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
)
|
||||
select I.[Level],I.[FromType],I.[Ordinal], I.[ParentID], I.[ItemID],I.[PreviousID],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged],
|
||||
C.[Number],C.[Text],C.[Type],C.[FormatID],C.[Config],C.[DTS] As [cDTS],C.[UserID] As [cUserID],C.[LastChanged] As [cLastChanged] from ItemZ I
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
order by I.[Level] , I.[FromType], I.[Ordinal]
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getItemNextAndChildren Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getItemNextAndChildren Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vefn_AllSections] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_AllSections]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||
DROP FUNCTION [vefn_AllSections];
|
||||
GO
|
||||
|
||||
-- Select .dbo.vefn_AllSections(10001) MyTypeSection, .dbo.vlnfn_AllSections(20001) MyTypeStep, .dbo.vlnfn_AllSections(5) MyTypeProc
|
||||
CREATE FUNCTION [dbo].[vefn_AllSections](@type int)
|
||||
RETURNS int
|
||||
AS
|
||||
BEGIN
|
||||
IF(@type < 20000 and @type >= 10000)
|
||||
RETURN 10000
|
||||
RETURN @type
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_AllSections Succeeded'
|
||||
ELSE PRINT 'ScalarFunction Creation: vefn_AllSections Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vefn_AnnotationTypeSplit] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_AnnotationTypeSplit]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||
DROP FUNCTION [vefn_AnnotationTypeSplit];
|
||||
GO
|
||||
|
||||
/*
|
||||
select * from vefn_AnnotationTypeSplit('1,4')
|
||||
select * from vefn_AnnotationTypeSplit(null)
|
||||
select * from vefn_AnnotationTypeSplit('')
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[vefn_AnnotationTypeSplit](@AnnotationTypeList varchar(MAX))
|
||||
RETURNS @IDs TABLE
|
||||
(
|
||||
TypeID int PRIMARY KEY,
|
||||
Name varchar(100)
|
||||
)
|
||||
AS
|
||||
BEGIN
|
||||
IF(isnull(@AnnotationTypeList,'') = '')
|
||||
Insert into @IDs
|
||||
Select TypeID, Name
|
||||
from AnnotationTypes
|
||||
else
|
||||
Insert into @IDs
|
||||
Select TypeID,NAME
|
||||
from AnnotationTypes
|
||||
where TypeID in(select ID from vefn_SplitInt(@AnnotationTypeList,','))
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_AnnotationTypeSplit Succeeded'
|
||||
ELSE PRINT 'TableFunction Creation: vefn_AnnotationTypeSplit Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vefn_DocVersionSplit] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_DocVersionSplit]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||
DROP FUNCTION [vefn_DocVersionSplit];
|
||||
GO
|
||||
|
||||
/*
|
||||
select * from vefn_DocVersionSplit('1,4')
|
||||
select * from vefn_DocVersionSplit(null)
|
||||
select * from vefn_DocVersionSplit('')
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[vefn_DocVersionSplit](@DocVersionList varchar(MAX))
|
||||
RETURNS @IDs TABLE
|
||||
(
|
||||
VersionID int PRIMARY KEY,
|
||||
ItemID int,
|
||||
DVPath varchar(MAX)
|
||||
)
|
||||
AS
|
||||
BEGIN
|
||||
IF(isnull(@DocVersionList,'') = '')
|
||||
Insert into @IDs
|
||||
Select VersionID, ItemID, dbo.ve_GetFolderPath(VersionID)
|
||||
from DocVersions where ItemID is not null
|
||||
else
|
||||
Insert into @IDs
|
||||
Select ID, ItemID, dbo.ve_GetFolderPath(VersionID)
|
||||
from vefn_SplitInt(@DocVersionList,',') as T
|
||||
join DocVersions DV on VersionID = T.ID
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_DocVersionSplit Succeeded'
|
||||
ELSE PRINT 'TableFunction Creation: vefn_DocVersionSplit Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vefn_FirstLink] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FirstLink]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||
DROP FUNCTION [vefn_FirstLink];
|
||||
GO
|
||||
|
||||
/*
|
||||
select .dbo.vefn_FirstLink('asdasdadsasd' + char(21) + 'asdasdasd\vasdasdasd', 2)
|
||||
select .dbo.vefn_FirstLink('asdasdadsasd' + char(21) + 'asdasdasd\vasdasdasd', 1)
|
||||
select .dbo.vefn_FirstLink('asdasdadsasd' + char(21) + 'asdasdasd\vasdasdasd', 0)
|
||||
*/
|
||||
|
||||
CREATE FUNCTION [dbo].[vefn_FirstLink](@text nvarchar(MAX),@includeLink int)
|
||||
RETURNS int
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @index int
|
||||
SET @index = 0
|
||||
if(@includeLink = 2)
|
||||
RETURN 0
|
||||
if(@includeLink = 1)
|
||||
return CHARINDEX('\v' , @text)
|
||||
DECLARE @index2 int
|
||||
SET @index = PATINDEX('%[' + nchar(9574)+nchar(9516)+nchar(21) + ']%',@text)
|
||||
return @index
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_FirstLink Succeeded'
|
||||
ELSE PRINT 'ScalarFunction Creation: vefn_FirstLink Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vefn_SplitInt] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_SplitInt]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||
DROP FUNCTION [vefn_SplitInt];
|
||||
GO
|
||||
|
||||
--select * from DocVersions where VersionID in(select * from vefn_SplitInt('1,2,4',','))
|
||||
--select Type, Count(*) from Contents where Type in(select * from vefn_SplitInt('20001,20002,20004',',')) group by Type
|
||||
CREATE FUNCTION [dbo].[vefn_SplitInt](@text varchar(MAX), @delimiter varchar(20) = ',')
|
||||
RETURNS @IDs TABLE
|
||||
(
|
||||
ID int PRIMARY KEY
|
||||
)
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @index int
|
||||
SET @index = -1
|
||||
WHILE (LEN(@text) > 0)
|
||||
BEGIN
|
||||
SET @index = CHARINDEX(@delimiter , @text)
|
||||
IF (@index = 0) AND (LEN(@text) > 0)
|
||||
BEGIN
|
||||
INSERT INTO @IDs VALUES (CAST(@text AS INT ))
|
||||
BREAK
|
||||
END
|
||||
IF (@index > 1)
|
||||
BEGIN
|
||||
INSERT INTO @IDs VALUES (CAST(LEFT(@text, @index - 1) AS INT))
|
||||
SET @text = RIGHT(@text, (LEN(@text) - @index))
|
||||
END
|
||||
ELSE
|
||||
SET @text = RIGHT(@text, (LEN(@text) - @index))
|
||||
END
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_SplitInt Succeeded'
|
||||
ELSE PRINT 'TableFunction Creation: vefn_SplitInt Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vefn_SplitROSearch] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_SplitROSearch]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||
DROP FUNCTION [vefn_SplitROSearch];
|
||||
GO
|
||||
|
||||
/*
|
||||
select * from vefn_SplitROSearch(null)
|
||||
select * from vefn_SplitROSearch('')
|
||||
select * from vefn_SplitROSearch('1')
|
||||
select * from vefn_SplitROSearch('1:0001')
|
||||
select * from vefn_SplitROSearch('1:0001000019C')
|
||||
select * from vefn_SplitROSearch('1:0001000019C,0001000019D')
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[vefn_SplitROSearch](@text varchar(MAX)='')
|
||||
RETURNS @ROIDSearch TABLE
|
||||
(
|
||||
RODBID int,
|
||||
ROID varchar(16)
|
||||
--,CONSTRAINT ROIDSearchPK PRIMARY KEY(RODBID, ROID)
|
||||
)
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @index int
|
||||
IF(isnull(@text,'') = '')
|
||||
BEGIN
|
||||
Insert into @ROIDSearch
|
||||
Select RODBID, ''
|
||||
from RODbs
|
||||
RETURN
|
||||
END
|
||||
SET @index = CHARINDEX(':' , @text)
|
||||
DECLARE @RODBID int
|
||||
IF (@index = 0) AND (LEN(@text) > 0)
|
||||
BEGIN
|
||||
SET @RODBID = CAST(@text AS INT)
|
||||
INSERT INTO @ROIDSearch VALUES (@RODBID,'')
|
||||
SET @Text=''
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SET @RODBID = CAST(LEFT(@text, @index - 1) AS INT)
|
||||
SET @text = RIGHT(@text, (LEN(@text) - @index))
|
||||
SET @index = -1
|
||||
END
|
||||
SET @text = RIGHT(@text, (LEN(@text) - @index))
|
||||
WHILE (LEN(@text) > 0)
|
||||
BEGIN
|
||||
SET @index = CHARINDEX(',' , @text)
|
||||
IF (@index = 0) AND (LEN(@text) > 0)
|
||||
BEGIN
|
||||
INSERT INTO @ROIDSearch VALUES (@RODBID,@text)
|
||||
BREAK
|
||||
END
|
||||
IF (@index > 1)
|
||||
BEGIN
|
||||
INSERT INTO @ROIDSearch VALUES (@RODBID,LEFT(@text, @index - 1))
|
||||
SET @text = RIGHT(@text, (LEN(@text) - @index))
|
||||
END
|
||||
ELSE
|
||||
SET @text = RIGHT(@text, (LEN(@text) - @index))
|
||||
END
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_SplitROSearch Succeeded'
|
||||
ELSE PRINT 'TableFunction Creation: vefn_SplitROSearch Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vesp_SearchAnnotationItemAndChildren] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_SearchAnnotationItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_SearchAnnotationItemAndChildren];
|
||||
GO
|
||||
|
||||
/*
|
||||
exec vesp_SearchAnnotationItemAndChildren Null,Null,'1',Null,0
|
||||
exec vesp_SearchAnnotationItemAndChildren Null,Null,'2',Null,0
|
||||
exec vesp_SearchAnnotationItemAndChildren Null,Null,'3',Null,0
|
||||
exec vesp_SearchAnnotationItemAndChildren Null,Null,'4',Null,0
|
||||
exec vesp_SearchAnnotationItemAndChildren Null,Null,'5',Null,0
|
||||
exec vesp_SearchAnnotationItemAndChildren Null,Null,'',Null,0
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[vesp_SearchAnnotationItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX), @AnnotationTypeList varchar(MAX), @SearchString varchar(MAX), @CaseSensitive as int) WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
Declare @Delim char(1)
|
||||
Set @Delim=char(7)
|
||||
Declare @DelimNumber char(1)
|
||||
Set @DelimNumber=char(17)
|
||||
Declare @DelimStep char(1)
|
||||
Set @DelimStep='.'
|
||||
Set @SearchString = .dbo.vefn_FixSearchString(@SearchString)
|
||||
begin
|
||||
with Itemz(DVPath, [Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [FromType], [ContentID], [DTS], [UserID], [LastChanged],[pContentID],
|
||||
[pDTS],[pUserID],[pLastChanged],PPath, Path, IsRNO, POrdinalPath, OrdinalPath) as (
|
||||
Select DVPath, 0 [Level], 0 [ParentID], 0 [Ordinal], [I].[ItemID], [PreviousID],0 [FromType],[I].[ContentID],[I].[DTS],[I].[UserID],[I].[LastChanged]
|
||||
,0 as [pContentID],[I].[DTS] As [pDTS], [I].[UserID] As [pUserID], [I].[LastChanged] As [pLastChanged],
|
||||
Cast('' as nvarchar(max)) PPath,
|
||||
Cast(Case when C.Type < 20000 then @Delim + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
|
||||
0 IsRNO, Cast('' as nvarchar(max)) POrdinalPath, Cast('0001' as nvarchar(max)) OrdinalPath
|
||||
FROM [Items] I
|
||||
Join Contents C on C.ContentID=I.ContentID
|
||||
JOIN vefn_DocVersionSplit(@DocVersionList) DV
|
||||
ON I.[ItemID] = DV.[ItemID]
|
||||
Union All
|
||||
-- Children
|
||||
select DVPath, [Level] + 1,Z.ItemID,0, I.[ItemID], I.[PreviousID], P.[FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,P.[ContentID] as [pContentID],P.[DTS] As [pDTS],P.[UserID] As [pUserID],P.[LastChanged] As [pLastChanged]
|
||||
,PATH + --''
|
||||
case C.Type/10000
|
||||
when 2 then
|
||||
case P.FromType
|
||||
when 3 then @DelimStep + 'Caution'
|
||||
when 4 then @DelimStep + 'Note'
|
||||
else '' end
|
||||
else '' end
|
||||
PPath,
|
||||
Path + case C.Type/10000
|
||||
when 0 then @Delim +C.Number + @DelimNumber + C.Text
|
||||
when 1 then @Delim +C.Number + @DelimNumber + C.Text
|
||||
else
|
||||
case P.FromType
|
||||
--when 1 then 'PRC' + @Delim + cast(1 as varchar(3))
|
||||
--when 2 then 'SEC' + @Delim + cast(1 as varchar(3))
|
||||
when 3 then @DelimStep +'Caution' + @DelimStep + cast(1 as varchar(3))
|
||||
when 4 then @DelimStep +'Note' + @DelimStep + cast(1 as varchar(3))
|
||||
when 5 then @DelimStep +'RNO' + @DelimStep
|
||||
when 7 then @DelimStep +'Table' + @DelimStep
|
||||
else case when Z.FromType < 3 then @Delim else @DelimStep end + cast(1 as varchar(3))
|
||||
end end Path,
|
||||
case when P.FromType = 5 then -1 else 0 end IsRNO,
|
||||
OrdinalPath + '.' + Right('0000' + Cast(P.FromType as varchar(4)), 4) + '-' ,
|
||||
OrdinalPath + '.' + Right('0000' + Cast(P.FromType as varchar(4)), 4) + '-0001'
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
Union All
|
||||
-- Siblings
|
||||
select DVPath, [Level] ,Z.[ParentID],Z.[Ordinal] +1, I.[ItemID], I.[PreviousID], [FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,null,null,null,null
|
||||
,PPath,
|
||||
--'1' +
|
||||
PPath + case C.Type/10000
|
||||
when 0 then @Delim + C.Number + @DelimNumber + C.Text
|
||||
when 1 then @Delim + C.Number + @DelimNumber + C.Text
|
||||
else case when Path like '%.%' then @DelimStep else @Delim end + cast(Ordinal + 2 as varchar(3))
|
||||
end Path, 0,
|
||||
POrdinalPath,
|
||||
POrdinalPath + right('0000' + cast(Z.[Ordinal] + 2 as varchar(4)), 4)
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
--where Z.[Level] > 0
|
||||
)
|
||||
select DvPath, Path, I.[Level],I.[FromType],I.[Ordinal], I.[ParentID], I.[ItemID],I.[PreviousID],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged],
|
||||
C.[Number],C.[Text],C.[Type],C.[FormatID],C.[Config],C.[DTS] As [cDTS],C.[UserID] As [cUserID],C.[LastChanged] As [cLastChanged],
|
||||
[pContentID],[pDTS],[pUserID],[pLastChanged],AnnotationID SearchAnnotationID, SearchText, TT.Name AnnotationType,
|
||||
(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=[I].[ItemID]) [AnnotationCount],
|
||||
(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=[I].[ItemID]) [DocVersionCount],
|
||||
(SELECT COUNT(*) FROM [Items] [Next] WHERE [Next].[PreviousID]=[I].[ItemID]) [NextCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=[I].[ItemID]) [PartCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=[I].[ItemID]) [Transition_RangeIDCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=[I].[ItemID]) [Transition_ToIDCount],
|
||||
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[C].[ContentID]) [DetailCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[C].[ContentID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[C].[ContentID]) [ItemCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[C].[ContentID]) [cPartCount],
|
||||
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[C].[ContentID]) [RoUsageCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[C].[ContentID]) [TransitionCount],
|
||||
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[C].[ContentID]) [ZContentCount]
|
||||
from ItemZ I
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
left join Entries E on C.ContentID = E.ContentID
|
||||
left join Documents D on E.DocID = D.DocID
|
||||
join Annotations A on A.ItemID = I.ItemID
|
||||
join vefn_AnnotationTypeSplit(@AnnotationTypeList) TT on TT.TypeID=A.TypeID
|
||||
where
|
||||
(isnull(@SearchString,'')=''
|
||||
OR (@CaseSensitive = 1 AND A.SearchText like @SearchString Collate SQL_Latin1_General_CP1_CS_AS)
|
||||
OR (@CaseSensitive = 0 AND A.SearchText like @SearchString Collate SQL_Latin1_General_CP1_CI_AS))
|
||||
AND
|
||||
((isnull(@StepTypeList,'') = '' and dbo.vefn_AllSections(C.Type)>=10000)
|
||||
or
|
||||
((dbo.vefn_AllSections(C.Type) in (Select ID from vefn_SplitInt(@StepTypeList,',')))
|
||||
or
|
||||
(@StepTypeList like '%20040%' AND IsRNO = -1)))
|
||||
order by DvPath,OrdinalPath
|
||||
OPTION (MAXRECURSION 10000)
|
||||
END
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_SearchAnnotationItemAndChildren Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: vesp_SearchAnnotationItemAndChildren Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [vesp_SearchROItemAndChildren] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_SearchROItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_SearchROItemAndChildren];
|
||||
GO
|
||||
|
||||
/*
|
||||
exec vesp_SearchROItemAndChildren '1,2,4','20007','1:00010000019C,0001000002AE'
|
||||
exec vesp_SearchROItemAndChildren '1,2,4','','1:00010000019C,0001000002AE'
|
||||
exec vesp_SearchROItemAndChildren '1,2,4','20007','1:0001'
|
||||
exec vesp_SearchROItemAndChildren '1,2,4','20006','1'
|
||||
exec vesp_SearchROItemAndChildren '1,2,4','20006',''
|
||||
exec vesp_SearchROItemAndChildren '1,2,4',Null,Null
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[vesp_SearchROItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX), @ROSearchString varchar(MAX)) WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
Declare @Delim char(1)
|
||||
Set @Delim=char(7)
|
||||
Declare @DelimNumber char(1)
|
||||
Set @DelimNumber=char(17)
|
||||
Declare @DelimStep char(1)
|
||||
Set @DelimStep='.'
|
||||
begin
|
||||
with Itemz(DVPath, [Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [FromType], [ContentID], [DTS], [UserID], [LastChanged],[pContentID],
|
||||
[pDTS],[pUserID],[pLastChanged],PPath, Path, IsRNO, POrdinalPath, OrdinalPath) as (
|
||||
Select DVPath, 0 [Level], 0 [ParentID], 0 [Ordinal], [I].[ItemID], [PreviousID],0 [FromType],[I].[ContentID],[I].[DTS],[I].[UserID],[I].[LastChanged]
|
||||
,0 as [pContentID],[I].[DTS] As [pDTS], [I].[UserID] As [pUserID], [I].[LastChanged] As [pLastChanged],
|
||||
Cast('' as nvarchar(max)) PPath,
|
||||
Cast(Case when C.Type < 20000 then @Delim + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
|
||||
0 IsRNO, Cast('' as nvarchar(max)) POrdinalPath, Cast('0001' as nvarchar(max)) OrdinalPath
|
||||
|
||||
FROM [Items] I
|
||||
Join Contents C on C.ContentID=I.ContentID
|
||||
JOIN vefn_DocVersionSplit(@DocVersionList) DV
|
||||
ON I.[ItemID] = DV.[ItemID]
|
||||
Union All
|
||||
-- Children
|
||||
select DVPath, [Level] + 1,Z.ItemID,0, I.[ItemID], I.[PreviousID], P.[FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,P.[ContentID] as [pContentID],P.[DTS] As [pDTS],P.[UserID] As [pUserID],P.[LastChanged] As [pLastChanged]
|
||||
,PATH + --''
|
||||
case C.Type/10000
|
||||
when 2 then
|
||||
case P.FromType
|
||||
when 3 then @DelimStep + 'Caution'
|
||||
when 4 then @DelimStep + 'Note'
|
||||
else '' end
|
||||
else '' end
|
||||
PPath,
|
||||
--Path + case when Z.FromType < 3 then @Delim else @DelimStep end + case C.Type/10000
|
||||
Path + case C.Type/10000
|
||||
when 0 then @Delim +C.Number + @DelimNumber + C.Text
|
||||
when 1 then @Delim +C.Number + @DelimNumber + C.Text
|
||||
else
|
||||
case P.FromType
|
||||
--when 1 then 'PRC' + @Delim + cast(1 as varchar(3))
|
||||
--when 2 then 'SEC' + @Delim + cast(1 as varchar(3))
|
||||
when 3 then @DelimStep +'Caution' + @DelimStep + cast(1 as varchar(3))
|
||||
when 4 then @DelimStep +'Note' + @DelimStep + cast(1 as varchar(3))
|
||||
when 5 then @DelimStep +'RNO' + @DelimStep
|
||||
when 7 then @DelimStep +'Table' + @DelimStep
|
||||
else case when Z.FromType < 3 then @Delim else @DelimStep end + cast(1 as varchar(3))
|
||||
end end Path,
|
||||
case when P.FromType = 5 then -1 else 0 end IsRNO,
|
||||
OrdinalPath + '.' + Right('0000' + Cast(P.FromType as varchar(4)), 4) + '-' ,
|
||||
OrdinalPath + '.' + Right('0000' + Cast(P.FromType as varchar(4)), 4) + '-0001'
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
Union All
|
||||
-- Siblings
|
||||
select DVPath, [Level] ,Z.[ParentID],Z.[Ordinal] +1, I.[ItemID], I.[PreviousID], [FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,null,null,null,null
|
||||
,PPath,
|
||||
--'1' +
|
||||
PPath + case C.Type/10000
|
||||
when 0 then @Delim + C.Number + @DelimNumber + C.Text
|
||||
when 1 then @Delim + C.Number + @DelimNumber + C.Text
|
||||
else case when Path like '%.%' then @DelimStep else @Delim end + cast(Ordinal + 2 as varchar(3))
|
||||
end Path, 0,
|
||||
POrdinalPath,
|
||||
POrdinalPath + right('0000' + cast(Z.[Ordinal] + 2 as varchar(4)), 4)
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
--where Z.[Level] > 0
|
||||
)
|
||||
select DvPath, Path, I.[Level],I.[FromType],I.[Ordinal], I.[ParentID], I.[ItemID],I.[PreviousID],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged],
|
||||
C.[Number],C.[Text],C.[Type],C.[FormatID],C.[Config],C.[DTS] As [cDTS],C.[UserID] As [cUserID],C.[LastChanged] As [cLastChanged],
|
||||
[pContentID],[pDTS],[pUserID],[pLastChanged],
|
||||
(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=[I].[ItemID]) [AnnotationCount],
|
||||
(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=[I].[ItemID]) [DocVersionCount],
|
||||
(SELECT COUNT(*) FROM [Items] [Next] WHERE [Next].[PreviousID]=[I].[ItemID]) [NextCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=[I].[ItemID]) [PartCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=[I].[ItemID]) [Transition_RangeIDCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=[I].[ItemID]) [Transition_ToIDCount],
|
||||
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[C].[ContentID]) [DetailCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[C].[ContentID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[C].[ContentID]) [ItemCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[C].[ContentID]) [cPartCount],
|
||||
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[C].[ContentID]) [RoUsageCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[C].[ContentID]) [TransitionCount],
|
||||
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[C].[ContentID]) [ZContentCount]
|
||||
from ItemZ I
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
left join Entries E on C.ContentID = E.ContentID
|
||||
left join Documents D on E.DocID = D.DocID
|
||||
where
|
||||
I.ContentID in(select Distinct ContentID from ROUsages RU
|
||||
join vefn_SplitROSearch(@ROSearchString) RR
|
||||
ON RR.RODBID = RU.RODBID and
|
||||
RU.ROID like RR.ROID + '%' Collate SQL_Latin1_General_CP1_CI_AS)
|
||||
AND
|
||||
((isnull(@StepTypeList,'') = '' and dbo.vefn_AllSections(C.Type)>=10000)
|
||||
or
|
||||
((dbo.vefn_AllSections(C.Type) in (Select ID from vefn_SplitInt(@StepTypeList,',')))
|
||||
or
|
||||
(@StepTypeList like '%20040%' AND IsRNO = -1)))
|
||||
order by DvPath,OrdinalPath
|
||||
OPTION (MAXRECURSION 10000)
|
||||
END
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_SearchROItemAndChildren Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: vesp_SearchROItemAndChildren Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [ve_GetFolderPath] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ve_GetFolderPath]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||
DROP FUNCTION [ve_GetFolderPath];
|
||||
GO
|
||||
|
||||
/*
|
||||
|
||||
Select VersionID,Name,dbo.ve_GetFolderPath(VersionID) from DocVersions order by VersionID
|
||||
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[ve_GetFolderPath] (@VersionID int) RETURNS varchar(MAX) WITH EXECUTE AS OWNER AS BEGIN
|
||||
declare @Path varchar(MAX);
|
||||
with Folderz(Level, FolderID, Path) as (
|
||||
Select 1 Level, FolderID,CAST(Name as varchar(MAX))
|
||||
from DocVersions I
|
||||
where VersionID = @VersionID
|
||||
Union All
|
||||
--
|
||||
Select FS.ParentID - (Select ParentID from Folders where FolderID = FS.ParentID), ParentID, CAST(Name + char(7) + Path as varchar(MAX))
|
||||
from Folders FS
|
||||
join Folderz FZ on FS.FolderID = FZ.FolderID
|
||||
where FS.FolderID <> FS.ParentID
|
||||
)
|
||||
select @Path = path From Folderz where Level = 0
|
||||
return @Path
|
||||
END;
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'ScalarFunction Creation: ve_GetFolderPath Succeeded'
|
||||
ELSE PRINT 'ScalarFunction Creation: ve_GetFolderPath Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [ve_GetPath] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ve_GetPath]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||
DROP FUNCTION [ve_GetPath];
|
||||
GO
|
||||
|
||||
/*
|
||||
select ItemID, CC.Type, dbo.ve_GetPath(ItemID)
|
||||
from Items II join Contents CC on II.ContentID = CC.ContentID
|
||||
where ItemID in(111,265,266,267)
|
||||
*/
|
||||
-- drop function ve_GetPath
|
||||
CREATE FUNCTION [dbo].[ve_GetPath] (@ItemID int) RETURNS varchar(max) WITH EXECUTE AS OWNER AS BEGIN
|
||||
-- declare @STructID int
|
||||
--set @StructID=11
|
||||
declare @Path varchar(max);
|
||||
with Itemz(ItemCount,ItemID,PreviousID,FromType,CType,Number,Text,PPath, Path) as (
|
||||
Select 1,ItemID,PreviousID,0,C.Type/10000,C.Number,C.Text,
|
||||
Cast(Case when C.Type < 20000 then '`' + C.Number +'`' + C.Text else '' end as nvarchar(max)) PPath,
|
||||
Cast(Case when C.Type < 20000 then '`' + C.Number +'`' + C.Text else '1' end as nvarchar(max)) Path
|
||||
from Items I
|
||||
join Contents C on I.ContentID = C.ContentID
|
||||
where ItemID=@ItemID
|
||||
Union All
|
||||
-- siblings
|
||||
Select ItemCount+1,I.PreviousID,II.PreviousID,0,C.Type/10000,Z.Number,Z.Text,PPath,cast(ItemCount + 1 as nvarchar(3)) + PPath
|
||||
from Items I
|
||||
join Contents C on I.ContentID = C.ContentID
|
||||
Join Items II on II.ItemID = I.PreviousID
|
||||
Join Itemz Z on I.ItemID=Z.ItemID
|
||||
where I.PreviousID != 0
|
||||
Union All
|
||||
-- children
|
||||
select 1,I.ItemID,I.PreviousID,P.FromType,C.Type/10000,C.Number,C.Text,
|
||||
case C.Type/10000
|
||||
when 0 then '`' + C.Number +'`' + C.Text
|
||||
when 1 then '`' + C.Number +'`' + C.Text +'`' + cast(ItemCount + 0 as varchar(3))
|
||||
else
|
||||
case P.FromType
|
||||
when 1 then 'PRC`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 2 then '`SEC`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 3 then '`Caution`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 4 then '`Note`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 5 then '`RNO`'
|
||||
when 7 then '`Table`'
|
||||
else '`' + cast(ItemCount + 0 as varchar(3))
|
||||
end end + PPath PPath,
|
||||
--'1' +
|
||||
case C.Type/10000
|
||||
when 0 then '`' + C.Number +'`' + C.Text
|
||||
when 1 then '`' + C.Number +'`' + C.Text +'`' + cast(ItemCount + 0 as varchar(3))
|
||||
else
|
||||
case P.FromType
|
||||
when 1 then 'PRC`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 2 then '`SEC`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 3 then '`Caution`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 4 then '`Note`' + cast(ItemCount + 0 as varchar(3))
|
||||
when 5 then '`RNO'
|
||||
when 7 then '`Table'
|
||||
else '`' + cast(ItemCount + 0 as varchar(3))
|
||||
end end + PPath Path
|
||||
|
||||
from Parts P
|
||||
join Items I on I.ContentID = P.ContentID
|
||||
join Contents C on I.ContentID = C.ContentID
|
||||
join Itemz Z on P.ItemID=Z.ItemID
|
||||
)
|
||||
select @Path = path From Itemz where ItemCount=1 and CType=0
|
||||
OPTION (MAXRECURSION 10000)
|
||||
return @Path
|
||||
END;
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'ScalarFunction Creation: ve_GetPath Succeeded'
|
||||
ELSE PRINT 'ScalarFunction Creation: ve_GetPath Error on Creation'
|
||||
GO
|
5
PROMS/VEPROMS.CSLA.Library/Sql commands/Tables.sql
Normal file
5
PROMS/VEPROMS.CSLA.Library/Sql commands/Tables.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
select II.ItemID, dbo.ve_GetPath(II.[ItemID]), Text from Parts PP
|
||||
join Items II on II.ItemID=PP.ItemID
|
||||
join Contents CC on II.ContentID = CC.ContentID
|
||||
|
||||
where FromType=7
|
@@ -0,0 +1,6 @@
|
||||
use VEPROMS
|
||||
set nocount on
|
||||
select contentid, cast(text as varchar(100)) from contents where contentid = 1140
|
||||
select itemid from items where contentid = 1140
|
||||
select TOId, RangeID from transitions where fromid = 1140
|
||||
select roid from rousages where contentid = 1140
|
@@ -0,0 +1,6 @@
|
||||
use VEPROMS
|
||||
set nocount on
|
||||
select contentid, cast(text as varchar(50)) from contents where contentid = 1140
|
||||
select itemid from items where contentid = 1140
|
||||
select TOId, RangeID from transitions where fromid = 1140
|
||||
select roid from rousages where contentid = 1140
|
@@ -0,0 +1,31 @@
|
||||
|
||||
/****** Object: StoredProcedure [getROImageByRODbID_FileName_DTS] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getROImageByRODbID_FileName_DTS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getROImageByRODbID_FileName_DTS];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getROImageByRODbID_FileName_DTS]
|
||||
(
|
||||
@RODbID int,
|
||||
@FileName nvarchar(255),
|
||||
@DTS datetime
|
||||
)
|
||||
AS
|
||||
SELECT
|
||||
[ImageID],
|
||||
[RODbID],
|
||||
[FileName],
|
||||
[Content],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(*) FROM [Figures] WHERE [Figures].[ImageID]=[ROImages].[ImageID]) [FigureCount]
|
||||
FROM [ROImages]
|
||||
WHERE [RODbID]=@RODbID AND [FileName]=@FileName AND [DTS]=@DTS
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getROImageByRODbID_FileName_DTS Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getROImageByRODbID_FileName_DTS Error on Creation'
|
||||
GO
|
@@ -0,0 +1,32 @@
|
||||
|
||||
/****** Object: StoredProcedure [vefn_FixSearchString] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FixSearchString]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||
DROP FUNCTION [vefn_FixSearchString];
|
||||
GO
|
||||
|
||||
/*
|
||||
select ID,ss,.dbo.vefn_FixSearchString(ss)
|
||||
from (
|
||||
select 1 ID,'%' ss union
|
||||
select 2 ID,'50[%]' ss union
|
||||
select 3 ID,'IF%' ss union
|
||||
select 4 ID,'%then:' ss union
|
||||
select 5 ID,'530`F' ss union
|
||||
select 6 ID,'check' ss union
|
||||
select 7 ID,'RCP%Cooling' ss) tt order by ID
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[vefn_FixSearchString](@SearchString varchar(MAX))
|
||||
RETURNS varchar(MAX)
|
||||
AS
|
||||
BEGIN
|
||||
-- This code adds % at the beginning and end if the beginning and end
|
||||
-- of the search string if it does not have % at the beginning or end
|
||||
IF(@SearchString like '[%]%') RETURN @SearchString
|
||||
IF(@SearchString like '%[%]') RETURN @SearchString
|
||||
RETURN '%' + @SearchString + '%'
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_FixSearchString Succeeded'
|
||||
ELSE PRINT 'ScalarFunction Creation: vefn_FixSearchString Error on Creation'
|
||||
GO
|
@@ -0,0 +1,94 @@
|
||||
|
||||
/****** Object: StoredProcedure [vefn_RemoveExtraText] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_RemoveExtraText]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||
DROP FUNCTION [vefn_RemoveExtraText];
|
||||
GO
|
||||
|
||||
/*
|
||||
select text, .dbo.vefn_RemoveExtraText(text,2,0,0) StrippedText from Contents where ContentID=373
|
||||
select text, .dbo.vefn_RemoveExtraText(text,1,0,0) StrippedText from Contents where ContentID=373
|
||||
select text, .dbo.vefn_RemoveExtraText(text,0,0,0) StrippedText ,.dbo.vefn_FirstLink(text,0), PATINDEX('%[' + nchar(9516) + nchar(9574) + char(21) + ']%' , text) from Contents where ContentID=373
|
||||
select .dbo.vefn_RemoveExtraText('\b Bold\b0',0,0,0)
|
||||
select .dbo.vefn_RemoveExtraText('\b Bold\b0',0,1,0)
|
||||
select .dbo.vefn_RemoveExtraText('A\u1?B\u12?C\u123?D\u1234?E',0,0,0)
|
||||
select .dbo.vefn_RemoveExtraText('A\u1?B\u12?C\u123?D\u1234?E',0,0,1)
|
||||
*/
|
||||
|
||||
|
||||
CREATE FUNCTION [dbo].[vefn_RemoveExtraText](@text nvarchar(MAX),@includeLink int, @includeRtfFormatting int , @includeSpecialCharacters int)
|
||||
RETURNS varchar(MAX)
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @index int
|
||||
DECLARE @index2 int
|
||||
SET @index = .dbo.vefn_FirstLink(@text,@includeLink)
|
||||
while (@index != 0)
|
||||
BEGIN
|
||||
SET @index2 = CHARINDEX('\v0' , @text)
|
||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index2+3,len(@text))
|
||||
SET @index = .dbo.vefn_FirstLink(@text,@includeLink)
|
||||
END
|
||||
if(@includeRtfFormatting=0)
|
||||
-- Remove Rtf Formatting
|
||||
BEGIN
|
||||
SET @text = Replace(@text, '\b0 ', '');
|
||||
SET @text = Replace(@text, '\b ', '');
|
||||
SET @text = Replace(@text, '\ul0 ', '');
|
||||
SET @text = Replace(@text, '\ul ', '');
|
||||
SET @text = Replace(@text, '\i0 ', '');
|
||||
SET @text = Replace(@text, '\i ', '');
|
||||
SET @text = Replace(@text, '\super ', '');
|
||||
SET @text = Replace(@text, '\sub ', '');
|
||||
SET @text = Replace(@text, '\nosupersub ', '');
|
||||
SET @text = Replace(@text, '\b0', '');
|
||||
SET @text = Replace(@text, '\b', '');
|
||||
SET @text = Replace(@text, '\ul0', '');
|
||||
SET @text = Replace(@text, '\ul', '');
|
||||
SET @text = Replace(@text, '\i0', '');
|
||||
SET @text = Replace(@text, '\i', '');
|
||||
SET @text = Replace(@text, '\super', '');
|
||||
SET @text = Replace(@text, '\sub', '');
|
||||
SET @text = Replace(@text, '\nosupersub', '');
|
||||
END
|
||||
if(@includeSpecialCharacters=0)
|
||||
-- Remove Special Characters
|
||||
BEGIN
|
||||
SET @index = PATINDEX('%\u[0-9]?%',@text)
|
||||
while(@index != 0)
|
||||
BEGIN
|
||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index+4,len(@text))
|
||||
SET @index = PATINDEX('%\u[0-9]?%',@text)
|
||||
END
|
||||
SET @index = PATINDEX('%\u[0-9][0-9]?%',@text)
|
||||
while(@index != 0)
|
||||
BEGIN
|
||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index+5,len(@text))
|
||||
SET @index = PATINDEX('%\u[0-9][0-9]?%',@text)
|
||||
END
|
||||
SET @index = PATINDEX('%\u[0-9][0-9][0-9]?%',@text)
|
||||
while(@index != 0)
|
||||
BEGIN
|
||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index+6,len(@text))
|
||||
SET @index = PATINDEX('%\u[0-9][0-9][0-9]?%',@text)
|
||||
END
|
||||
SET @index = PATINDEX('%\u[0-9][0-9][0-9][0-9]?%',@text)
|
||||
while(@index != 0)
|
||||
BEGIN
|
||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index+7,len(@text))
|
||||
SET @index = PATINDEX('%\u[0-9][0-9][0-9][0-9]?%',@text)
|
||||
END
|
||||
SET @index = PATINDEX('%\''[0-9A-Fa-f][0-9A-Fa-f]%',@text)
|
||||
while(@index != 0)
|
||||
BEGIN
|
||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index+4,len(@text))
|
||||
SET @index = PATINDEX('%\''[0-9A-Fa-f][0-9A-Fa-f]%',@text)
|
||||
END
|
||||
|
||||
END
|
||||
RETURN @text
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_RemoveExtraText Succeeded'
|
||||
ELSE PRINT 'ScalarFunction Creation: vefn_RemoveExtraText Error on Creation'
|
||||
GO
|
@@ -0,0 +1,140 @@
|
||||
|
||||
/****** Object: StoredProcedure [vesp_SearchItemAndChildren] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_SearchItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_SearchItemAndChildren];
|
||||
GO
|
||||
|
||||
/*
|
||||
exec vesp_SearchItemAndChildren '1,2,4','20007','%#Link:Transition%',1,0,0,0
|
||||
exec vesp_SearchItemAndChildren '1,2,4','20007','%#Link:Transition%',1,1,0,0
|
||||
exec vesp_SearchItemAndChildren '1,2,4','20007','%#Link:Transition%',1,2,0,0
|
||||
exec vesp_SearchItemAndChildren '4','','%#Link:Refer%',1,2,0,0
|
||||
exec vesp_SearchItemAndChildren '4','','%200`F%',0,1,0,0
|
||||
exec vesp_SearchItemAndChildren '4','10000','',0,0,0,0
|
||||
exec vesp_SearchItemAndChildren '4','','%[0-9]`F%',0,1,0,0
|
||||
exec vesp_SearchItemAndChildren '4','','%WATER%',0,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','','',0,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','20040','',0,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','10000','XYZZY',0,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','10000','XYZZY',1,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','','%IF%',0,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','','%IF%',1,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','','%47%',1,0,0,0
|
||||
exec vesp_SearchItemAndChildren '','','%47%',1,0,0,1
|
||||
exec vesp_SearchItemAndChildren '','','%condenser not av%',0,0,0,0
|
||||
*/
|
||||
CREATE PROCEDURE [dbo].[vesp_SearchItemAndChildren] (@DocVersionList varchar(MAX), @StepTypeList varchar(MAX),
|
||||
@SearchString varchar(MAX), @CaseSensitive as int, @IncludeLinks as int, @IncludeRtfFormatting as int, @IncludeSpecialCharacters as int) WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
Declare @Delim char(1)
|
||||
Set @Delim=char(7)
|
||||
Declare @DelimNumber char(1)
|
||||
Set @DelimNumber=char(17)
|
||||
Declare @DelimStep char(1)
|
||||
Set @DelimStep='.'
|
||||
Set @SearchString = .dbo.vefn_FixSearchString(@SearchString)
|
||||
begin
|
||||
with Itemz(DVPath, [Level], [ParentID], [Ordinal], [ItemID], [PreviousID], [FromType], [ContentID], [DTS], [UserID], [LastChanged],[pContentID],
|
||||
[pDTS],[pUserID],[pLastChanged],PPath, Path, IsRNO, POrdinalPath, OrdinalPath) as (
|
||||
Select DVPath, 0 [Level], 0 [ParentID], 0 [Ordinal], [I].[ItemID], [PreviousID],0 [FromType],[I].[ContentID],[I].[DTS],[I].[UserID],[I].[LastChanged]
|
||||
,0 as [pContentID],[I].[DTS] As [pDTS], [I].[UserID] As [pUserID], [I].[LastChanged] As [pLastChanged],
|
||||
Cast('' as nvarchar(max)) PPath,
|
||||
Cast(Case when C.Type < 20000 then @Delim + C.Number + @DelimNumber + C.Text else '1' end as nvarchar(max)) Path,
|
||||
0 IsRNO, Cast('' as nvarchar(max)) POrdinalPath, Cast('0001' as nvarchar(max)) OrdinalPath
|
||||
FROM [Items] I
|
||||
Join Contents C on C.ContentID=I.ContentID
|
||||
JOIN vefn_DocVersionSplit(@DocVersionList) DV
|
||||
ON I.[ItemID] = DV.[ItemID]
|
||||
Union All
|
||||
-- Children
|
||||
select DVPath, [Level] + 1,Z.ItemID,0, I.[ItemID], I.[PreviousID], P.[FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,P.[ContentID] as [pContentID],P.[DTS] As [pDTS],P.[UserID] As [pUserID],P.[LastChanged] As [pLastChanged]
|
||||
,PATH + --''
|
||||
case C.Type/10000
|
||||
when 2 then
|
||||
case P.FromType
|
||||
when 3 then @DelimStep + 'Caution'
|
||||
when 4 then @DelimStep + 'Note'
|
||||
else '' end
|
||||
else '' end
|
||||
PPath,
|
||||
Path + case C.Type/10000
|
||||
when 0 then @Delim +C.Number + @DelimNumber + C.Text
|
||||
when 1 then @Delim +C.Number + @DelimNumber + C.Text
|
||||
else
|
||||
case P.FromType
|
||||
--when 1 then 'PRC' + @Delim + cast(1 as varchar(3))
|
||||
--when 2 then 'SEC' + @Delim + cast(1 as varchar(3))
|
||||
when 3 then @DelimStep +'Caution' + @DelimStep + cast(1 as varchar(3))
|
||||
when 4 then @DelimStep +'Note' + @DelimStep + cast(1 as varchar(3))
|
||||
when 5 then @DelimStep +'RNO' + @DelimStep
|
||||
when 7 then @DelimStep +'Table' + @DelimStep
|
||||
else case when Z.FromType < 3 then @Delim else @DelimStep end + cast(1 as varchar(3))
|
||||
end end Path,
|
||||
case when P.FromType = 5 then -1 else 0 end IsRNO,
|
||||
OrdinalPath + '.' + Right('0000' + Cast(P.FromType as varchar(4)), 4) + '-' ,
|
||||
OrdinalPath + '.' + Right('0000' + Cast(P.FromType as varchar(4)), 4) + '-0001'
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
Union All
|
||||
-- Siblings
|
||||
select DVPath, [Level] ,Z.[ParentID],Z.[Ordinal] +1, I.[ItemID], I.[PreviousID], [FromType],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged]
|
||||
,null,null,null,null
|
||||
,PPath,
|
||||
--'1' +
|
||||
PPath + case C.Type/10000
|
||||
when 0 then @Delim + C.Number + @DelimNumber + C.Text
|
||||
when 1 then @Delim + C.Number + @DelimNumber + C.Text
|
||||
else case when Path like '%.%' then @DelimStep else @Delim end + cast(Ordinal + 2 as varchar(3))
|
||||
end Path, 0,
|
||||
POrdinalPath,
|
||||
POrdinalPath + right('0000' + cast(Z.[Ordinal] + 2 as varchar(4)), 4)
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
--where Z.[Level] > 0
|
||||
)
|
||||
select DvPath, Path, I.[Level],I.[FromType],I.[Ordinal], I.[ParentID], I.[ItemID],I.[PreviousID],I.[ContentID],I.[DTS],I.[UserID],I.[LastChanged],
|
||||
C.[Number],C.[Text],C.[Type],C.[FormatID],C.[Config],C.[DTS] As [cDTS],C.[UserID] As [cUserID],C.[LastChanged] As [cLastChanged],
|
||||
[pContentID],[pDTS],[pUserID],[pLastChanged],
|
||||
(SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=[I].[ItemID]) [AnnotationCount],
|
||||
(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=[I].[ItemID]) [DocVersionCount],
|
||||
(SELECT COUNT(*) FROM [Items] [Next] WHERE [Next].[PreviousID]=[I].[ItemID]) [NextCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=[I].[ItemID]) [PartCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=[I].[ItemID]) [Transition_RangeIDCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=[I].[ItemID]) [Transition_ToIDCount],
|
||||
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[C].[ContentID]) [DetailCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[C].[ContentID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[C].[ContentID]) [ItemCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[C].[ContentID]) [cPartCount],
|
||||
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[C].[ContentID]) [RoUsageCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[C].[ContentID]) [TransitionCount],
|
||||
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[C].[ContentID]) [ZContentCount]
|
||||
from ItemZ I
|
||||
join Contents C on C.ContentID = I.ContentID
|
||||
left join Entries E on C.ContentID = E.ContentID
|
||||
left join Documents D on E.DocID = D.DocID
|
||||
where
|
||||
(isnull(@SearchString,'')=''
|
||||
OR (@CaseSensitive = 1 AND .dbo.vefn_RemoveExtraText(C.Text,@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CS_AS)
|
||||
OR (@CaseSensitive = 0 AND .dbo.vefn_RemoveExtraText(C.Text,@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS)
|
||||
OR (@CaseSensitive = 1 AND D.DocAscii like @SearchString Collate SQL_Latin1_General_CP1_CS_AS)
|
||||
OR (@CaseSensitive = 0 AND D.DocAscii like @SearchString Collate SQL_Latin1_General_CP1_CI_AS))
|
||||
AND
|
||||
((isnull(@StepTypeList,'') = '' and dbo.vefn_AllSections(C.Type)>=10000)
|
||||
or
|
||||
((dbo.vefn_AllSections(C.Type) in (Select ID from vefn_SplitInt(@StepTypeList,',')))
|
||||
or
|
||||
(@StepTypeList like '%20040%' AND IsRNO = -1)))
|
||||
order by DvPath,OrdinalPath
|
||||
OPTION (MAXRECURSION 10000)
|
||||
END
|
||||
END
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_SearchItemAndChildren Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: vesp_SearchItemAndChildren Error on Creation'
|
||||
GO
|
Reference in New Issue
Block a user