473,396 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1009
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

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

Similar topics

3
by: Jarrod Morrison | last post by:
Hi all Im relatively new to using stored procedures and im not sure if it is possible to do what I am trying to do so any help here is greatly appreciated. I am using the variable @MachineName...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
7
by: Anthony Robinson | last post by:
Have been encountering an odd issue. Every now and again, certain packages of stored procedures just become invalid. I'm aware that dropping or altering an underlying table would render a package...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
7
by: Paul Aspinall | last post by:
Hi I have developed a C# app which uses SQL Stored procs... which I plan to deploy as a single / low user version on MSDE. My SP's all have 'meaningful' names. However, as I want to protect my...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
11
by: peter | last post by:
I am trying to get a SQL stored procedure to use user maintained MQT implicitly which raises questions on when they are used or not used. In theory you would expect the stored procedure to pick up...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.