Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to “store” stored procedures

Author  Topic 

BobLewiston
Starting Member

29 Posts

Posted - 2009-04-01 : 21:39:18
I've written a few SQL stored procedures in a text editor. But how do I actually "store" them in (add them to?) a database using SQL Server 2008 Management Studio Express? I've tried to research this topic in Management Studio's onboard Help, but apparently Help assumes I know more about the subject than I actually do, because I don't even see the relevance of the answers I'm getting to my questions. Any help would be appreciated, including pointing me to a good SQL tutorial that assumes the reader knows nothing, yet teaches more than the bare-bones minimum.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-04-01 : 22:54:22
From a query window you can execute t-sql code. LIke:
Select getdate()

To execute the code, hit F5, or click the green arrow on the tool bar.

another t-sql command is:
Create procecure <procName> as
<t-sql code>
go

When you execute that code the procedure will be compiled in whatever database you are currently connected to. So you need to figure out how to open a query window, connect to your server, and select your database.

Let us know if you need more help...

Be One with the Optimizer
TG
Go to Top of Page

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-04-02 : 05:13:01
Stored procedures are "stored" as soon as you run the CREATE PROCEDURE...... command which contains the actual procedure code. You can view procedures which have already been created by opening Management Studio, expand the database, then programability , then stored procedures.

If you right click on the stored procedures folder you will get an option to create a new procedure. Or if you right click on an existing procedure you can select alter procedure to view the code and make changes if necessary.

http://www.w3schools.com/sql/default.asp
http://www.java2s.com/Code/SQLServer/Store-Procedure-Function/Create-Procedure.htm
Go to Top of Page
   

- Advertisement -