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
 Create or Alter procedure

Author  Topic 

tulikar
Starting Member

1 Post

Posted - 2007-11-13 : 00:36:33
I want to use Create a procedure if not exisit and Alter it if exisit.

Can I use Create and Alter keyword together while writing a procedure in SQL Server 2005? If YES than HOW?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-13 : 01:39:09
This is the Create Procedure template from QA

-- =============================================
-- Create procedure basic template
-- =============================================
-- creating the store procedure
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = N'<procedure_name, sysname, proc_test>'
AND type = 'P')
DROP PROCEDURE <procedure_name, sysname, proc_test>
GO

CREATE PROCEDURE <procedure_name, sysname, proc_test>
<@param1, sysname, @p1> <datatype_for_param1, , int> = <default_value_for_param1, , 0>,
<@param2, sysname, @p2> <datatype_for_param2, , int> = <default_value_for_param2, , 0>
AS
SELECT @p1, @p2
GO

-- =============================================
-- example to execute the store procedure
-- =============================================
EXECUTE <procedure_name, sysname, proc_test> <value_for_param1, , 1>, <value_for_param2, , 2>
GO



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-11-13 : 01:53:26
http://databases.about.com/od/sqlserver/a/storedprocedure.htm
http://www.informit.com/articles/article.aspx?p=25288&rl=1

these will help u

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA

######################
IMPOSSIBLE = I+M+POSSIBLE
Go to Top of Page
   

- Advertisement -