CREATE or REPLACE feature request

I remember back when I moved from Oracle to 6.5 I found the lack of a create or replace really annoying. Whenever I create new sps I always curse at not being able to do "create or replace myproc..." having to do "if exists (select 1 information_schema...)" or "if object_id(...) is not null" or "if not exists(select 1 from sys.objects..)" is really annoying, especially as there are so many different options.

So I go to connect to put a suggestion and find one already there.

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=127219

So if you want this implemented go and vote



-
Published 19 October 2006 00:59 by simonsabin

Comments

08 July 2007 06:10 by Jeff Moden

# re: CREATE or REPLACE feature request

For procs, view, and functions, the easy way is...

    IF OBJECT_ID('dbo.<objectname>') IS NOT NULL

       DROP <objecttype> dbo.<objectname>

08 July 2007 19:43 by simonsabin

# re: CREATE or REPLACE feature request

I do mention that as an option, however the issue with that is that you have to drop the object. Which means you have to recreate permissions, extended properties, anything attached to the object. Having an CREATE of ALTER would avoid that.

And I don't see why it is so difficult to implement

08 July 2007 21:36 by Jeff Moden

# re: CREATE or REPLACE feature request

Guess just 'cause it's not Oracle (thank goodness). ;-)  And, CREATE OR REPLACE doesn't work on tables anyway...

I agree that CREATE OR REPLACE would be nice... so would a "Modified Date" and a "Connect By".  But if you really want to see something where you'd also remark "I don't see why it is so difficult to implement", you should try using Oracle's UPDATE statement when a join is present ;-)  I don't even bother using it anymore since they came out with MERGE.

I'll gladly work in SQL Server instead of Oracle (or many other databases) even though it doesn't have a CREATE OR REPLACE ;-)

Anyway... just having a little fun here... good "meeting" you, Simon...