By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,266 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,266 IT Pros & Developers. It's quick & easy.

Regarding stored procedure help me

P: 24
Hi
I want to know how to write storedprocedure when search creiteria is Present.

Here the query to give the list of

"select ID, Salesmennummer , Salesname Commision, Areacode from sales_master

Areacode Salesmennummer Salesname Commision
1 1000 Rams 200
2 2000 Johny 1000


I Want to search above list by areacode or Salesmennummer or Salesname.

so PlZ help me how to write storedprocedure for this.

Thanq.
Feb 12 '09 #1
Share this Question
Share on Google+
5 Replies


ammoos
100+
P: 100
Create procedure [OWNER].[PROCEDURE NAME]
@areacode integer
as
begin
select ID, Salesmennummer , Salesname Commision, Areacode from sales_master
where Areacode=@areacode
end

GO
Feb 12 '09 #2

P: 24
Thanq for ur reply .I tried like

CREATE PROCEDURE [dbo].[salesearch]

@sales_code int,
@sales_name varchar(50),
@area_code int
AS

set nocount on;
select sales_code,sales_name,area_code from sales where sales_code=@sales_code and sales_name=@sales_name
and area_code=@area_code
GO


but i got err like" Procedure 'salesearch' expects parameter '@sales_code', which was not supplied."
what it mean
Thanq
Feb 12 '09 #3

100+
P: 152
gpl
It means that you have not provided all 3 parameters when you ran it
Feb 12 '09 #4

P: 24
Iam new to storedprocedures will u tell me hw to provide parameters
Feb 12 '09 #5

dafodil
100+
P: 392
Different languages have different ways of passing parameters to SQL stored procedures. Try to read this and view the other links connected to this site:
http://msdn.microsoft.com/en-us/library/ms190669.aspx

Heres about parameters:
http://msdn.microsoft.com/en-us/library/ms189260.aspx
Feb 12 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.