Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Not Working
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Query Not Working
Divers
Thread ID:
01406608
Message ID:
01406608
Vues:
110
I'm trying to add in the @Status:

Here's the data:
ReturnId    WarehouseId SerialNo     Details       Status ActionDate
----------- ----------- -----------  ------------- ------ -----------------------
1           20          NULL         Details 1     NULL   2009-06-17 09:01:44.240
2           20          NULL         Carlsbad      NULL   2009-06-17 09:08:10.533
I want the add into my sproc the option to pass in a status code, or none:
CREATE PROCEDURE ap_GetReturnsForWarehouse
	@WarehouseId INT,
	@Status		 TINYINT = NULL
	
AS
BEGIN

	SELECT	r.*, 
			p.PartNo, 
			p.Description,
			u.FullName,
			w.Caption AS Warehouse
		FROM Returns r
		JOIN Parts p ON p.PartId = r.PartId
		JOIN Warehouses w ON w.WarehouseId = r.WarehouseId
		JOIN Users u ON u.UserId = r.UserId
		WHERE r.WarehouseId = @WarehouseId AND
			  r.Status = ISNULL(@Status, r.Status)
		ORDER BY p.PartNo, r.SerialNo DESC

END
I'm calling it like this:
exec ap_GetReturnsForWarehouse @WarehouseId = 20, @Status = NULL
I'm getting no data back.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform