Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stored Proc Problem
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01394196
Message ID:
01394222
Vues:
39
Ok, here it is.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE bm_GetClients
	@CompanyKey		INT = NULL,
	@ClientKey		INT = NULL

AS
BEGIN

	SELECT *
		FROM bm_Clients
		WHERE (CompanyKey = @CompanyKey OR @CompanyKey IS NULL) AND
			  (ClientKey = @ClientKey OR @ClientKey IS NULL)
END
If I call it with:
DECLARE @CompanyKey INT
DECLARE @ClientKey INT
SET  @CompanyKey = 2
SET @ClientKey = 5
EXEC  bm_GetClients @CompanyKey = @CompanyKey, @ClientKey = @ClientKey
Then it works ok.




>Can you post actual query?
>
>>Same result. Passing only the client key returns 0 records.
>>
>>
>>
>>>Try
>>>
>>>SELECT *
>>>		FROM bm_Clients
>>>		WHERE (CompanyKey = @CompanyKey OR @CompanyKey IS NULL)
>>>			AND
>>>			  (ClientKey = @ClientKey OR @ClientKey IS NULL)
>>>
>>>>This stored proc takes 2 optional params.
>>>>
>>>>

>>>>
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform