Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored Procedure

Author  Topic 

rajeshkumar77
Starting Member

46 Posts

Posted - 2001-12-06 : 21:34:55
Hi,
I have a sql query like this.
i am using sql server 2000.

select eno, ename, sal from emp where eno='10'

how can i write stored procedure for this above query.
if anybody knows about stored procedure please give me help.
Thanksin advance
Yours
Rajesh

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2001-12-06 : 21:41:33
A stored procedure is just that, a procedure that is stored.

You create it with

Create Procedure MyProcName

AS

Select eno, ename, sal from emp where eno= 10



However, if you want to be able to pass parameters, you do it like this



Create Procedure MyProcName

@eno int

AS

Select eno, ename, sal from emp where eno= @eno




Look in books online for more info on stored procedures, also there is a whole topic here http://www.sqlteam.com/FilterTopics.asp?TopicID=102

A little bit of reading will give you heaps of info


Damian
Go to Top of Page

PiecesOfEight
Posting Yak Master

200 Posts

Posted - 2001-12-06 : 21:44:29
create proc foo
@eno int //declare appropriate datatype
as
select eno, ename, sal from emp where eno=@eno

//usage
foo @eno = 10


Go to Top of Page

rajeshkumar77
Starting Member

46 Posts

Posted - 2001-12-07 : 00:45:14
Thankyou VeryMuch
This is woring fine.
I have a doubt. Is it possible to Create Stored Procedures in MS Access ?
Thankyou VeryMuch
Yours
Rajesh

Create Procedure MyProcName

AS

Select eno, ename, sal from emp where eno= 10



However, if you want to be able to pass parameters, you do it like this



Create Procedure MyProcName

@eno int

AS

Select eno, ename, sal from emp where eno= @eno

[/code]

Go to Top of Page

sona
Yak Posting Veteran

68 Posts

Posted - 2001-12-07 : 00:47:50
No Rajesh you cannot create stored procedures in MSAccess

Go to Top of Page
   

- Advertisement -