Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2007-07-25 : 03:46:31
|
@ItemID ------>input parameter to stored procedureIf (@ItemID=Null) 'if null is passed as parameter value.......execute if condition queryelse execute else condition query ('if null is not passed as the )parameter what is the exact syntax for writing such type of stored proceduresI have written query as follows (How to write it exactly)If Not ISNULL(@ItemID,N'') SELECT DeliveryDetail.DeliveryNumber, DeliveryDetail.ItemID, DeliveryDetail.DeliverdQty, DeliveryDetail.OrderNumber, DeliveryDetail.OrderLineNumber FROM DeliveryDetail INNER JOIN InvoiceHeader ON DeliveryDetail.DeliveryNumber = InvoiceHeader.DeliveryNumber WHERE (InvoiceHeader.CompanyID = @CompanyID) AND (InvoiceHeader.DivisionID = @DivisionID) AND (InvoiceHeader.DepartmentID = @DepartmentID) AND (InvoiceHeader.InvoiceNumber = @InvoiceNumber)AND (DeliveryDetail.ItemID=@ItemID) else SELECT DeliveryDetail.DeliveryNumber, DeliveryDetail.ItemID, DeliveryDetail.DeliverdQty, DeliveryDetail.OrderNumber, DeliveryDetail.OrderLineNumber FROM DeliveryDetail INNER JOIN InvoiceHeader ON DeliveryDetail.DeliveryNumber = InvoiceHeader.DeliveryNumber WHERE (InvoiceHeader.CompanyID = @CompanyID) AND (InvoiceHeader.DivisionID = @DivisionID) AND (InvoiceHeader.DepartmentID = @DepartmentID) AND (InvoiceHeader.InvoiceNumber = @InvoiceNumber) |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-25 : 05:40:50
|
If @ItemID is not null_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
|
|
|
|
|