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
Divers
Thread ID:
01400408
Message ID:
01400411
Vues:
56
That did it. Thanks. I don't get why what I had didn't work.


>>I have a stored procedure called ap_LookupPart. It must be provided a warehouse Id and a part no. The Serial number is optional. If
>>I don't pass a serialno, no data is returned. I don't understand why this isn't working:
>>
>>
>>CREATE PROCEDURE ap_LookupPart
>>	@WarehouseId	INT,
>>	@PartNo			VARCHAR(30),
>>	@SerialNo		VARCHAR(30) = NULL
>>	
>>AS
>>BEGIN
>>
>>	SELECT i.*, p.PartNo, p.Description, l.Location, w.WarehouseCode, w.Caption AS Warehouse
>>		FROM Inventory i
>>		JOIN Parts p ON p.PartId = i.PartId
>>		JOIN Locations l ON l.LocationId = i.LocationId
>>		JOIN Warehouses w ON w.WarehouseId = i.WarehouseId
>>		WHERE w.WarehouseId = @WarehouseId AND
>>			  p.PartNo = @PartNo AND
>>			  i.SerialNo = ISNULL(@SerialNo, i.SerialNo)
>>
>>END
>>
>
>Kevin,
>
>Do you have NULLs in the SerialNo column?
>
>Try AND (@SerialNo IS NULL OR i.SerailNo = @SerialNo) instead of iSerialNo = ISNULL(@SerialNo, i.SerialNo)
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