Hi, please bear with me here :) I have a stored procedure with three parameters, two XML files and a contains clause (for simplicity's sake, assume it is one word). 1) XML1: a list of files that have entries in the database, that is being sent over from another database they are in2) XML2: a list of allowed file types ("extensions") we can return3) the contains clauseNow, the error may not be with the contains like I think it may be - basically it is only returning the documents it finds in the XML document "@xmlFileList", ignoring the other rows found in the second SELECT.I am doing a union here. The first SELECT is all file types in the database that have matching names to the XML files and extensions sent in. This is UNIONed with the second SELECT, which is all files that DON'T have the same names (to remove duplicates) and where it CONTAINS certain keywords in the fulltext search. I need to compile a list and return it. However, if the description column and the keyword column in the row do not match, the result is ignored! I.E. if a keyword is found in one, but not the other, the row is not picked. Why is this?Here is the simplified SQL:SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROC [dbo].[GetAssetList]( @xmlFileList varchar(1000), @strContainsClause varchar(1000), @xmlFileTypes varchar(1000))ASBEGIN SET NOCOUNT ON DECLARE @intDocHandle int, @intFileTypeHandle int, @err int...--prepare XMLdocs SELECT DISTINCT AssetsMaster.AssetMasterUID, AssetsMaster.Extension, AssetsMaster.Description, AssetsMaster.Keywords FROM AssetsMaster, OPENXML (@intDocHandle, '/NewDataSet/Table',2) WITH (FILENAME varchar(256)) AS x, OPENXML (@intFileTypeHandle, '/NewDataSet/Table',2) WITH (FILETYPE varchar(256)) AS y, SupportedFiles WHERE AssetsMaster.AssetFileName = x.FILENAME AND AssetsMaster.Extension = SupportedFiles.Extension AND AssetsMaster.Extension = y.FILETYPE UNION SELECT DISTINCT AssetsMaster.AssetMasterUID, AssetsMaster.Extension, AssetsMaster.Description, AssetsMaster.Keywords FROM AssetsMaster, OPENXML (@intDocHandle, '/NewDataSet/Table',2) WITH (FILENAME varchar(256)) AS x, OPENXML (@intFileTypeHandle, '/NewDataSet/Table',2) WITH (FILETYPE varchar(256)) AS y, SupportedFiles WHERE AssetsMaster.AssetFileName <> x.FILENAME AND CONTAINS ((Description, Keywords), @strContainsClause) AND AssetsMaster.Extension = SupportedFiles.Extension AND AssetsMaster.Extension = y.FILETYPE ORDER BY AssetsMaster.Downloads DESC EXEC sp_xml_removedocument @intDocHandle EXEC sp_xml_removedocument @intFileTypeHandleENDGOSET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGO
Sample input:exec GetAssetList @xmlFileList='<NewDataSet> <Table> <FILENAME>test.doc</FILENAME> </Table></NewDataSet>',@strContainsClause='"manage" ',@xmlFileTypes='<NewDataSet><Table><FILETYPE>DOC</FILETYPE></Table><NewDataSet>'
Any ideas?Thanks,James