473,787 Members | 2,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Full Stored Procedures?

95 New Member
Hi frnds, can somebody has the full material of stored procedures, cz i have no knowledge regarding it.

1) How to Create Stored procedures?
2) Why they are used?
3) When they are created?
4)What is the need of stored Procedures?

Your Reply will be highlt appreciated.
Feb 27 '08 #1
7 1333
sleepydog3
7 New Member
At the core a stored procedure (proc) is a saved select/insert/update/delete statement.

You use a PROC automate repetitive taskes and reduce changes for errors additionally you can get performance enchance from a well formed PROC.

PROC's also reduce the threat of SQL injection attacks on your DB.

You can create a PROC at any time. before durning and after development.


http://msdn2.microsoft.com/en-us/library/ms187926.aspx
Feb 27 '08 #2
Delerna
1,134 Recognized Expert Top Contributor
Hi sonia
You've asked a few questions about stored procedures, you must be having fun coming to terms with them.

1) Open enterprise manager and using the tree view on the left.
a) Open the database you want to work with.
b) Right click on 'stored procedures' (assuming you are right handed)
c) Select 'New Stored Procedure' from the context menu.
A window with something like this will open.
Expand|Select|Wrap|Line Numbers
  1.    CREATE PROCEDURE [OWNER].[PROCEDURE NAME] AS
  2.  
you will need to change it to something like this
Expand|Select|Wrap|Line Numbers
  1.    CREATE PROCEDURE prYourProceduresName 
  2.        --here you can put a list of parameters that must be provided 
  3.        --when you call the procedure from somewhere. for example
  4.        @FirstParam int, @SecondParam varchar(50), @ThirdParam datetime
  5.    AS
  6.       -- This is where you put the code that performs the desired functionality
  7.       --  For example
  8.     SELECT @FirstParam, @SecondParam,@ThirdParam 
  9.    GO
  10.  
now if you execute the following code in query analyser
Expand|Select|Wrap|Line Numbers
  1.    exec prYourProceduresName 2,'testing','2007-01-01'
  2.  
that should give you some idea of how to create and execute a stored procedure.
You can execute them from
other stored procedures
asp pages
access databases
windows scripting host
etc etc
Feb 27 '08 #3
Delerna
1,134 Recognized Expert Top Contributor
2) Why are they used.
Well they are used for many reasons but i think behind many of them is that stored procedures provide a mechanism that allows you to group a set of related actions together and have them all execute with a single call.

for example, suppose you had a task that required you to
deleted a set of records from 1 table
log who and when they were deleted into another table
save the deleted records into a third table.
return the contents of the first table after the deletion to the user.

suppose also that you were doing that from a web page via vb or java script.
Well you could carry out each of the above one at a time from the web page.
But there is the overhead of setting up data ojects to perform each function, network traffic caused between user and the SQL database etc

Wouldn't it be better to have all those things in a single stored procedure so that a single call to it from the web page caused all of that to happen on the server itself. All the web page has to do is call the proc and wait for and then display the records that were returned.

I hope that explanation helps you.
Just realise one thing.
How you actually use stored procedures is up to your own imagination
Feb 27 '08 #4
Delerna
1,134 Recognized Expert Top Contributor
3) When are they created
Well relating the question to terms of programming in c vb or java they are created at design time. They could be created and deleted on the fly, ie run time.But I can't think of any reason why you would want to.

4) What is the need of stored procedures
They were invented so as to provide you with a way of performing a set of tasks as a unit and to do it on the server so as to reduce the communication overheads between server and client. At least, thats my understanding.

Sonia, experiment with them and you will soon get the idea.
Look for sets of actions that are always carried out together in a sequence.
Also Update and delete queries.
All of these things are candidates for stored procedures.
Feb 27 '08 #5
sonia.sardana
95 New Member
Thx for replying both delerna and Sleepydog3.....
Hey on sql 2000, i m able to create Stored Procedures..... ..but on SQL 2005 when i rght click on database I want to work with..there is no stored Procedure....

Second thing I inserts the record into stored Procedure,Now i want to select the records from stored procedure.....S uppose my procedure name is ProSonia

I write ,,, Select * from ProSonia
It gives error.......
Feb 28 '08 #6
Delerna
1,134 Recognized Expert Top Contributor
try
exec ProSonia

instead of

select * from ProSonia

Although you havent posted the code for ProSonia so........

Anyway stored procedures are not views or tables and
select * from whatever
is for use with views and tables, not strored procedures


I've never used 2005 so I can't comment on that except to say
surely its not that different, is it?
Feb 28 '08 #7
sonia.sardana
95 New Member
ya there is not so much of difference between 2000 and 2005.

One diff is that in 2000 we have Query analyzer and Enterprise manager.
Query Analyzer--Where we write and execute Statements.
Enterprise manger--Where we see our tables and databases.

2005--Both are combined. To write statements,We click the New button on the top of the screen.....
Screen is divided into two parts-
L.H.S--Databases
R.H.S.---Write Statements.

Simple......... ...But in 2005 option to create Stored procedures is not same
Feb 28 '08 #8

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

Similar topics

1
5190
by: Perre Van Wilrijk | last post by:
Hi, I've got a full text index which works fine, SQLSERVER2000/WIN 2000 SERVER. The system requires to update indexes immediately, so I use a timestamp field to enable this. No problems so far. Now, I've got a stored procedures which nearly daily inserts about 10.000 rows. When doing this while full text indexing is active, all users start complaining about performance. In order to work around this problem I tried
11
10758
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures execute in the database server with better performance? Please advise good references for Oracle stored procedures also. thanks!!
2
2821
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 code in stored procedures (im advocating encryption of them). When deploying an application however stored procedure seem to add another level of complexity to installation. In future we also plan to have an basic ASP app with some of the...
2
9245
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 problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
5
3486
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored Procedures. I thought stored pricedures were an Oracle/MS SQL Server thing and don't know how they work with Access Jet. I've looked at some of the help on stored procedures in A2003, but really don't understand what's going on. Can someone...
45
3415
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
1
1720
by: pwbyrne | last post by:
Hi, I'm looking for details, or tools about porting a full Ms Sql Server 2000 database to Postgres on Linux. Is this possible? We have the whole nine yards, stored procedures, triggers, and all. Is there a way to automate this process?
28
72559
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and 2005 Test Environments. What is the purpose of a view if I can just copy the vode from a view and put it into a stored procedure? Should I be accessing views from stored procedures?
11
3445
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 the MQT at the time it is bound on the creation of the static SQL. This raises the question on how you stop it or start it using a MQT as there is no option on the bind. What happens when it is rebound? What happens if the plan is made invalid...
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10169
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.