what is Procedure? creating procedure

Posted by Fundaravi under Sql Server on 4/13/2012 | Points: 10 | Views : 856 | Status : [Member] | Replies : 15
Id Name Marks
101 Ravi 50
102 Raju 95

Create a stored procedure for above code and if u give id as input have to display the corresponding values like Name and Marks.so if you give null as id have to display all the values in the table?

Ravindra


Responses

Posted by: Sakthi.Singaravel on: 4/13/2012 [Member] Silver | Points: 25

Up
0
Down
Procedure:

Create Procedure Procedure-name
(
Input parameters ,
Output Parameters (If required)
)
As
Begin
Sql statement used in the stored procedure
End

for more details refer this link..

http://www.codeproject.com/Articles/126898/Sql-Server-How-to-write-a-Stored-procedure-in-Sql


Regards,
Singaravel M

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/13/2012 [Member] Silver | Points: 25

Up
0
Down
This MSDN reference also used fro u...

http://msdn.microsoft.com/en-us/library/aa258259(v=sql.80).aspx

Regards,
Singaravel M

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/14/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
Create Procedure procedurename(@action char(1),@id int,@name varchar(25), @marks int) as
begin
if(@action=s)
Select * from table name
end

Thanks & Regards
Hari

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kk86kiran on: 4/14/2012 [Member] Starter | Points: 25

Up
0
Down
create procedure mysp(@id int)
as
if(@id='')
begin
select * from tablename
end
else
begin
select name,marks from tablename where id=@id
end


exec mysp @id=''

you will get all records

exec mysp @id=1

u will get the records basing on id

k.m.j.kiran

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kk86kiran on: 4/14/2012 [Member] Starter | Points: 25

Up
0
Down
hi fundaravi,

try the above code i think it will be helpful to u

if it is useful plz mark it as answer

k.m.j.kiran

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi ..
if u Want Video Reference
http://www.youtube.com/watch?v=VfDbaW17JRo

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Create Procedure Sp_procedurename

@id int
As
begin
Select * from Table_name where id=@id
end


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/19/2012 [Member] Starter | Points: 25

Up
0
Down
HI,

CREATE PROCEDURE STUDETMARK
@STUDENTID INT
AS
SELECT * FROM STUDETMARKS WERE STUDENTID=@STUDENTID
GO

HOPE THIS WILL HELP

REGARDS
SRIRAM.R

sriram

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 5/21/2012 [Member] Bronze | Points: 25

Up
0
Down
Fundaravi

hi Have You Got The answer

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/19/2012 [Member] Bronze | Points: 25

Up
0
Down
Refer this link
http://msdn.microsoft.com/en-us/library/aa258259(v=sql.80).aspx

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/19/2012 [Member] Bronze | Points: 25

Up
0
Down
Refer this link too.
http://msdn.microsoft.com/en-us/library/ms187926.aspx


Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/19/2012 [Member] Silver | Points: 25

Up
0
Down
CREATE PROCEDURE displayMarkdetails(@id INT)

AS
IF(@id IS NULL)
BEGIN
SELECT * FROM Table_1
END
ELSE
BEGIN
SELECT * FROM Table_1 WHERE id=@id
END


To execute please run the following script,
EXEC displayMarkdetails NULL


EXEC displayMarkdetails 1


Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/19/2012 [Member] Silver | Points: 25

Up
0
Down
If you want to study more about SQL Server Stored Procedure,Please refer the following codeproject article,
http://www.codeproject.com/Articles/38682/Overview-of-SQL-Server-Stored-Procedure

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 6/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Ravi,
If u got the answer plz mark that one..


Thanks & Regards
Hari

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 7/31/2012 [Member] Silver | Points: 25

Up
0
Down
please mark it as answer....That helps other who search the same...

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response