Hi All,
Quick question, I have always heard it best practice to check for exist, if
so, drop, then create the proc. I just wanted to know why that's a best
practice. I am trying to put that theory in place at my work, but they are
asking for a good reason to do this before actually implementing. All I
could think of was that so when you're creating a proc you won't get an
error if the procedure already exists, but doesn't it also have to do with
Compilation and perhaps Execution. Does anyone have a good argument for
doing stored procs this way? All feedback is appreciated.
TIA,
~CK 3 4867
It is a limited scope attempt for correctly implementing UNIQUENESS on
all table rows...If you want to understand why it is a *good* practice
you need to learn more about rules of relational modeling and
especially database design and definition of primary keys...
Look for "Introducti on to Database Systems" from CJ Date (at Amazon)
Hope this helps...
CK wrote: Hi All, Quick question, I have always heard it best practice to check for exist, if so, drop, then create the proc. I just wanted to know why that's a best practice. I am trying to put that theory in place at my work, but they are asking for a good reason to do this before actually implementing. All I could think of was that so when you're creating a proc you won't get an error if the procedure already exists, but doesn't it also have to do with Compilation and perhaps Execution. Does anyone have a good argument for doing stored procs this way? All feedback is appreciated. TIA, ~CK
CK (c_**********@h otmail.com) writes: Quick question, I have always heard it best practice to check for exist, if so, drop, then create the proc. I just wanted to know why that's a best practice. I am trying to put that theory in place at my work, but they are asking for a good reason to do this before actually implementing. All I could think of was that so when you're creating a proc you won't get an error if the procedure already exists, but doesn't it also have to do with Compilation and perhaps Execution. Does anyone have a good argument for doing stored procs this way? All feedback is appreciated.
Nah, the best is to use ALTER if the procedure already exists, because
then you retein permissions on the procedure. In SQL 2005, you also
retain depenency information.
The problem is that there is no CREATE_OR_ALTER statment, so a pure
SQL script for installation, is most easiest written with IF EXISTS DROP
CREATE. To use ALTER in a pure SQL script, you would have to have the
procedure code in dynamic SQL, and that would be very difficult to
maintain.
The really best practice is to have some client-side load tool that
reads the procedure code and then replaces CREATE with ALTER as needed.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Hopefully this person posted the answer below to the wrong original
question, because his answer makes absolutely no sense....
Cimode wrote: It is a limited scope attempt for correctly implementing UNIQUENESS on all table rows...If you want to understand why it is a *good* practice you need to learn more about rules of relational modeling and especially database design and definition of primary keys... Look for "Introducti on to Database Systems" from CJ Date (at Amazon)
Hope this helps... CK wrote: Hi All, Quick question, I have always heard it best practice to check for exist, if so, drop, then create the proc. I just wanted to know why that's a best practice. I am trying to put that theory in place at my work, but they are asking for a good reason to do this before actually implementing. All I could think of was that so when you're creating a proc you won't get an error if the procedure already exists, but doesn't it also have to do with Compilation and perhaps Execution. Does anyone have a good argument for doing stored procs this way? All feedback is appreciated. TIA, ~CK This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniel |
last post by:
hi ng,
i am newbie to sqlserver and my problem seems simple, but i didn't find
information about it:
How can i display the
RETURN @x
value of a stored procedure in the sql analyzer of the sqlserver?
thanks a lot,
d
|
by: MD |
last post by:
I am trying to create a dynamic SQL statement to create a view.
I have a stored procedure, which based on the parameters passed calls
different stored procedures. Each of this sub stored procedure creates
a string of custom SQL statement and returns this string back to the
main stored procedure.
This SQL statements work fine on there own. The SQL returned from the
sub stored procedure are returned fine. The datatype of the variable
that...
|
by: Chad |
last post by:
Could any suggest to me a good way to programmatically identify which SPs
update a database column. I would like to create a cross reference for our
database.
|
by: xAvailx |
last post by:
I have a requirement that requires detection of rows deleted/updated by
other processes. My business objects call stored procedures to create,
read, update, delete data in a SQL Server 2000 data store. I've done
a fair amount of research on concurrency handling in newsgroups and
other resources. Below is what I've come up as a standard for
handling concurrency thru stored procedures. I am sharing with everyone
so I can get some comments...
|
by: Rhino |
last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a
Throwable back to the calling program as an OUT parameter?
If yes, what datatype should I use when registering the Throwable as an OUT
parameter and what datatype should I use in the CREATE PROCEDURE and DROP
PROCEDURE statements?
Here's what I tried:
- the method signature for the stored procedure included: Throwable
throwable
| |
by: Mike Hutton |
last post by:
I have a rather odd problem.
I have a SP which uses temp. tables along the way, and then returns a
table of results:
CREATE PROCEDURE dbo.usp_myproc(
@pNameList VARCHAR(6000)
)
AS
|
by: Wie |
last post by:
I need help.
How do I create a stored procedure with SQLCommand? I have tried following
string, but it doesn't work. I am using vs.net 2003 professional now.
dbCommand.CommandText = _
"CREATE PROCEDURE GetID" & vbCrLf & _
"@ID int out," & vbCrLf & _
"@Name varchar(20)" & vbCrLf & _
"AS" & vbCrLf & _
|
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?
|
by: yinzara |
last post by:
I have the following trigger that calls a DB2 stored procedure:
DROP TRIGGER GGWU.TRI_A_MULTI_PROP@
CREATE TRIGGER GGWU.TRI_A_MULTI_PROP AFTER INSERT ON
GGWU.MULTIPLIER_PROPERTY REFERENCING NEW AS POST FOR EACH ROW MODE
DB2SQL
BEGIN ATOMIC
CALL
GGWU.PKG_MULT_PROP_INSERT(POST.C_PROPERTY_CODE,POST.I_MULTIPLIER_ID);
END@
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |