469,309 Members | 2,754 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,309 developers. It's quick & easy.

Stored procedures Again

I create a stored procedure as follows-
CREATE PROCEDURE student1 @roll int, @name varchar
AS
SELECT @roll as roll, @name as name
GO


To execute it---
EXEC student1 1,'A'
Result comes

Again
EXEC student1 2 ,'B'
Result comes

In stored procedure name student1 , these two rows are inserted or not.....
If inserted how can i view rows of Stored Procedure....
Like in table we can view rows as--
Select * from table
Feb 28 '08 #1
2 897
ck9663
2,878 Expert 2GB
I create a stored procedure as follows-
CREATE PROCEDURE student1 @roll int, @name varchar
AS
SELECT @roll as roll, @name as name
GO


To execute it---
EXEC student1 1,'A'
Result comes

Again
EXEC student1 2 ,'B'
Result comes

In stored procedure name student1 , these two rows are inserted or not.....
If inserted how can i view rows of Stored Procedure....
Like in table we can view rows as--
Select * from table

No, those rows were not inserted.

Generally speaking, stored procedure (SP) does not store rows inside it. Tables are the most common way to store rows. SP's are just a collection of commands, queries, t-sqls that you gather together so that when you call it, it will execute all those commands and queries sequentially.

I found a good primer for you here

-- CK
Feb 28 '08 #2
Delerna
1,134 Expert 1GB
To continue what you have started here.
You need a table to save the values into
called perhaps tblStudents
with fields Roll and Name with datatypes int and varchar(50)


Now you can change youre stored proc to
Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE student1  @roll int, @name varchar(50)
  2. AS
  3.  
  4. --Insert a new row into tblStudents
  5. INSERT INTO tblStudents
  6. SELECT @roll as roll, @name as name
  7.  
  8. --Now return the contents of the student table to the caller
  9. SELECT roll,name
  10. FROM  tblStudents
  11.  
  12. GO
  13.  
now you can execute it like you were and get the results you were expecting

--Add the first record
EXEC student1 1,'A'

--now add the second record
EXEC student1 2 ,'B'


There you go, that should get you started and help you to follow the tutorial posted in the previous post
Feb 28 '08 #3

Post your reply

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

Similar topics

3 posts views Thread by Jarrod Morrison | last post: by
7 posts views Thread by Anthony Robinson | last post: by
8 posts views Thread by Thomasb | last post: by
2 posts views Thread by Kent Lewandowski | last post: by
7 posts views Thread by Paul Aspinall | last post: by
45 posts views Thread by John | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.