Hi, i''m tring to get a stored procedure to return all records by default if no values are passed to it.
So i have:
But this doesn't return any records as every record has at least one null value in it (mainly the last two fields)
And if i add something like:
Then it still doesn't work as when i pass a value into the parameter it returns records with that value and null values...
So i have:
Code:
Create Procedure qrySuppSearch
(
@Name nvarchar(50) = "%",
@Addy nvarchar(50) = "%",
@City nvarchar(50) = "%",
@Country nvarchar(50) = "%",
@TradeName nvarchar(50) = "%",
@Contact nvarchar(50) = "%"
)
As
SELECT tblSuppliers.SupplierID, tblSuppliers.SupplierName, tblSuppliers.Address, tblSuppliers.City,
tblSuppliers.Country, tblSuppliers.TradingName, tblSupplierContacts.ContactName
FROM tblSuppliers
LEFT JOIN tblSupplierContacts ON tblSuppliers.SupplierID = tblSupplierContacts.SupplierID
WHERE ((supplierName like @Name)
AND (Address like @Addy)
AND (City like @City)
AND (Country like @Country)
AND (TradingName like @TradeName)
AND (ContactName like @Contact))
But this doesn't return any records as every record has at least one null value in it (mainly the last two fields)
And if i add something like:
Code:
AND ((TradingName like @TradeName) OR (TradingName is NULL))
Then it still doesn't work as when i pass a value into the parameter it returns records with that value and null values...