Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Brain dead - SQL syntax
Message
 
 
À
07/09/2007 16:49:34
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01253096
Message ID:
01253208
Vues:
19
>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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform