Hi folks, I’m trying to write a store proc that will take tyre sizes from dropdown lists and the customer postcode from a textbox.
Everything works ok but I would like to take only the first 2 characters from the customer postcode to match against the Suppliers postcode, not really sure how to do this, thanks in advance
USE [DatabaseTest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[SearchResults] @Width int, @Profile int, @Diamete int, @Speed nvarchar, @CustPostcode nvarchar
As
Begin
SELECT Suppliers.SupplierID, Suppliers.SupplierName, Product.Width, Product.Profile, Product.Diamete, Product.Speed, Product.Brand, Product.TyreModel, Product.TyreType,
Product.RollingResistance, Product.WetGrip, Product.NoiseEmission, Product.ProductUnitSalePrice
FROM Product INNER JOIN
Suppliers ON Product.SupplierFK = Suppliers.SupplierID
WHERE Width = @Width and Product.Profile = @Profile and Product.Diamete = @Diamete and Product.Speed = @Speed andSuppliers.SupplierPostcode = @CustPostcode
ORDER BY Product.ProductUnitSalePrice ASC
End