Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Store Proc

$
0
0

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

 


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>