Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Brain dead - SQL syntax
Message
 
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01253096
Message ID:
01253208
Views:
20
>Was my answer clear? I get two lists of qualifiers one list is required qualifiers and the other is excluded qualifiers. The selected records must have all required qualifiers and none of the exluded qualifiers.

Hi Glenn,

Here's another one
CREATE PROCEDURE GetContactsByQualities2 
	@XmlInc varchar(4000), 
	@XmlExc varchar(4000)
AS

DECLARE @IdocInc int, @IdocExc int

DECLARE @Qids TABLE (QID int, Qtype int)

EXEC sp_xml_preparedocument @IdocInc OUTPUT, @XmlInc
EXEC sp_xml_preparedocument @IdocExc OUTPUT, @XmlExc

INSERT INTO @Qids
	SELECT *, +1 FROM OPENXML (@IdocInc, '/Root/QID',1) WITH (Val int)

INSERT INTO @Qids
	SELECT *, -1 FROM OPENXML (@IdocExc, '/Root/QID',1) WITH (Val int)

EXEC sp_xml_removedocument @IdocInc				
EXEC sp_xml_removedocument @IdocExc				

SELECT * FROM Contacts c
	WHERE (SELECT COUNT(*) FROM @Qids WHERE Qtype > 0) = 
		(SELECT SUM(Qtype) FROM @Qids JOIN ContactQualities  
				ON QID =  ContactQualities.qualifierid
					WHERE ContactQualities.contactid = c.id)
	
RETURN 0
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform