BEWARE RENAMING OBJECTS

  • Heres one that could catch you out if you are ever in a hurry and decide to rename some Stored Procs on a live system.

    Now I know we would all never do that without testing, but for those people in the real world whose boss thinks computers are magic boxes and results should be instantaneous watch out for this.

    If you have a stored proc and you want to make changes so you decide to rename the original and say copy the code to a new proc but with the original name becareful to check that the names of your procs actually match those of your stored proc code.

    Now I know EM won't let you change the name in the code unless it matches the object name but you can change the object name so that it doesn't match the code name.

    So lets say you add a new NameOfProc and you decide to call it NameOfProc and call the original NameOfProcOld.

    Now lets say as you got confused, tired, too much Guinness or whatever, in the code you actually left the name of the origianl as NameOfProc and in the new code the name is NameOfProcNew.

    Which does SQL Server run when you run:

    exec NameOfProc

    It runs the SP with an object name of NameOfProc even if in the SP definition (the code) it is called 'ANOTHER Proc'.

    Can lead to you banging your head off the wall.

    Nigel Moore
    ======================

  • Instead of banging your head on the wall go for more Guiness. As to your problem,... been there, done that, wish I could say I hadn't.

    quote:


    To err is human, to really really screw up it takes a computer


    Tim C.

    //Will write code for food

    One Windows to rule them all, One Windows to find them,

    One Windows to bring them all and in the darkness bind them

    In the Land of Microsoft where the Shadows lie.


    Tim C //Will code for food

  • Always create/chage objects from scripts stored in sourcesafe. In this way you will get a change history.

    Your problem will never arise because you will have run a script that deletes and creates the SP.

    You will also have to delete the original SP that you have renamed and decide what to do about it's script in sourcesafe.


    Cursors never.
    DTS - only when needed and never to control.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply