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.
| Author |
Topic |
|
loamguy
Starting Member
15 Posts |
Posted - 2008-02-26 : 16:02:37
|
| When I created an SP in Enterprise Manager, I didn't manually type in the existence check at the inception, a la "if exists (select * from sysobjects...)". I just started with the CREATE PROC AS statement.I noticed that if I generate a SQL script for the SP, SQL2000 automatically generates the existence check statement. My question is, can I assume that when the SP is actually executed, SQL2000 does the exists check on its own? I EXEC'd the proc in Query Analyzer with no errors. I just want to make sure that I don't need to enter the exists statement if it's already being done behind the scenes. |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2008-02-26 : 17:20:35
|
| I think you mixed two things into one: creating and executing sp.When you create one, sql will make sure another one with the same name is not already exist.When you exec one, sql need to make sure one is there for you to run.Otherwise, it will complaint. |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-02-27 : 01:28:42
|
| If you don't use the check on CREATE PROCEDURE , sql server will return a message , saying it already exists(that's if it already exists)Jack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
loamguy
Starting Member
15 Posts |
Posted - 2008-02-27 : 10:48:26
|
| Maybe I'm getting tripped up on the fact that there's a CREATE statement used in an sp that is already existing. When I execute an sp, is SQL Server actually re-creating the SP every time it runs? Since I didn't include an exists check in the sp, I'm guessing I would have received an error upon execution if SQL actually tried to create the sp when it was already there. |
 |
|
|
|
|
|
|
|