question

lala avatar image
lala asked

How to do stored procedure?

I need to do stored procedure for my project but I have no idea on starting it. Please help.

Thanks.

sql-server-2005stored-procedures
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TonyJ avatar image
TonyJ answered

Start by learning some basic SQL. You can do this by reading some basic articles in SQL Server Books On Line or on may web sites (SQLTeam.com, SQLServerCentral, SSWUG.org, etc, etc) then creating simple queries in your database or in one of the sample databases (download from microsoft.com) and looking at the SQL view.

Then to create a stored proc, if your using SQL Server 2005, open the Programmability folder, right-click on Stored Procedures and click New Stored Procedure. It will start by creating a stored proc from a template and you can go from there.

I found that it was best to look at a lot of samples, execute them and make a few changes to them before embarking on creating my own stored procs.

Good luck! Tony

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

RickD avatar image
RickD answered

Alternatively, if you want to code a procedure in T-SQL, look up CREATE PROCEDURE in Books Online (SQL's help file).

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rajib Bahar avatar image
Rajib Bahar answered

I'll point you to Aaron Bertrand's blog entry on best practices on stored procs. I think it'll be a good read for you.

See http://sqlblog.com/blogs/aaron_bertrand/archive/2008/10/30/my-stored-procedure-best-practices-checklist.aspx.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.