cancel
Showing results for 
Search instead for 
Did you mean: 

Query for gathering all keywords on a doc type in separate columns

Austin_Barber1
Star Contributor
Star Contributor

I've seen a couple older threads, but wanted to check and see if someone has figured out a way to gather all keywords on a doc type and separate them into their own column. Like others, I can gather the item name, but that is what the auto string is. Any idea on how to separate them out? I can generate a CSV file on all the documents and their keywords, but a query seems to be a better way then locking up the system. 

 

Thank you!

1 ACCEPTED ANSWER

Tim_Nice
Confirmed Champ
Confirmed Champ

I use this alot, I hope it helps

 

SELECT
dg.itemtypegroupnum as 'Doc Type Group Num',
rtrim(dg.itemtypegroupname) as 'Doc Type Group Name',
xr.itemtypenum as 'Doc Type Num',
rtrim(dt.itemtypename) as 'Doc Type Name',
--rtrim(dt.AUTONAMESTRING) as 'Auto-Name',
xr.keytypenum as 'Key Type Num',
rtrim(kt.keytype) as 'Key Type Name',
xr.seqnum as 'Seq',
--kt.KEYTYPEMASK as 'Mask',
KEYTYPEFLAGS as 'Flags',
DATATYPE as 'Data Type',
KEYTYPELEN as 'Length'
FROM [itemtypexkeyword] XR
JOIN DOCTYPE (NOLOCK) DT ON DT.ITEMTYPENUM = XR.ITEMTYPENUM
JOIN KEYTYPETABLE (NOLOCK) KT ON KT.KEYTYPENUM = XR.keytypenum
JOIN ITEMTYPEGROUP (NOLOCK) DG ON DG.itemtypegroupnum = DT.itemtypegroupnum
WHERE DT.ITEMTYPENAME IN ('<<<DOCUMENT TYPE NAME >>>')
ORDER BY dt.itemtypename, kt.keytype

View answer in original post

12 REPLIES 12

Roger_Linhart
Elite Collaborator
Elite Collaborator

@Austin Barber Are you looking for the Keyword Types associated with each Document Type or the Keyword values associated with all the documents in a Document Type? Can you provide an example of what the query results would look like?

Sorry for the delay. I would like to see the keyword values on a document in their own columns. It would pretty much be the same output as the generate csv does. 

 

Roger_Linhart
Elite Collaborator
Elite Collaborator

The following query provides a comma separated list of the Keyword Types associated with each Document Type:

 

/* KeywordsInDocTypesReport.sql * * Roger D. Linhart   11/20/2017   OnBase 17.0.0.57 * Jeff Pinkerton provided initial query. * * Show Keywords in Document Types. * * To list Keywords in all Document Types: *   --SET @myDocType = 'EA'; * * To list Keywords in Document Types LIKE 'EA%': *   SET @myDocType = 'EA'; * */DECLARE @myDocType nvarchar(51) = '';--SET @myDocType = 'EA';SET @myDocType += '%';SELECT DISTINCT rtrim(A.itemtypename) AS 'Document Type',	STUFF ((SELECT ', ' + rtrim(C.Keytype)		FROM hsi.itemtypexkeyword B WITH (NOLOCK)        INNER JOIN hsi.keytypetable C WITH (NOLOCK) ON B.keytypenum = C.keytypenum		WHERE  B.itemtypenum = A.itemtypenum		ORDER BY B.keytypenum		FOR XML PATH('')), 1, 1, '') AS KeywordsFROM hsi.doctype A WITH (NOLOCK)  WHERE (A.itemtypename LIKE @myDocType)

excellent!