Click here to Skip to main content

DINESH K MAURYA asked:

Open original thread
i have create a procedure and after executing it will show error msg.
 
Please help me
Must declare the scalar variable "@ArticleN".
 
/****** Object:  StoredProcedure [dbo].[vs_Models_SELECT]    Script Date: 11/20/2012 10:45:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Models]
 
AS
 

	SET NOCOUNT OFF;
 
Declare @CategoryID int
Declare @SubCategoryID int
Declare @SortExpression varchar(100)
Declare @Order varchar(100)
Declare  @ArticleN varchar(150)
 
set @CategoryID=6  
set @SubCategoryID=1   
set @SortExpression=NULL
set @Order=NULL
 

if @SortExpression is NULL 
Begin
set @SortExpression='p.SeriesId  '
End
 
if @Order is NULL 
Begin
set @Order ='Desc  '
End
 
declare @Sort varchar(200)
set @Sort=@SortExpression + @order
set @ArticleN=N'A P I INDIA';
 
declare @QueryString nvarchar(max)
 
		set @QueryString= ' Select  --ProductID ,
				Article_No as Model,
				p.SeriesId,
				s.SeriesDesc,
				p.CategoryId,
				ca.CategoryDesc,
				p.MaterialUsedId,
				m.MaterialUsedDesc,
				p.Size, 
				p.ColorId,
				c.ColorNameDesc,
				p.Gender,
				MRP ,
				p.Manufactured_In,
				Maunfacturing_Date,
				Input_Pairs,
				Soldout_Pairs,
     			Remaining_Pairs
 
		from tabproduct P
		inner join tblkpSeries s
		on p.SeriesId=s.SeriesId
		inner join tblkpCategory ca
		on p.CategoryId=ca.CategoryId
		inner join tblkpMaterialUsed m
		on p.MaterialUsedId=m.MaterialUsedId
 
		inner join tblkpColor c
		on p.ColorId=c.ColorId
 
		where 
   		  
		Manufactured_In=case when  @ArticleN  is null then Manufactured_In
			else @ArticleN
			end
	
 
		Order by ' + @Sort
 
PRINT @QueryString
 EXEC (@QueryString)
 
Thanks in advance..
Tags: SQL-Server

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100