My Script of database has changed field names

  • Hi all,

    I generated the script for all the stored procedures in my database and

    I noticed that in a very critical stored procedure ,the script has made some changes by itself.

    The change is shown below-

    Part of Real Stored procedure in Database-

    SELECT TCN_Site=tcn, TCN_Company =tcn, TCN_Parent =tcn, parent_pointer = parent_firm_id, firm_id = firm_or_site_id,

    completed = 'ppppppppppppppppppppp' , counter = -1 --default b4 write to #complete

    into #TCNult

    FROM dev_img_oloes.dbo.tcn_firm_or_site_master

    WHERE PARENT_FIRM_ID is null

    The Same part in the script-

    SELECT TCN_Site=UCN, TCN_Company =UCN, TCN_Parent =UCN, parent_pointer = parent_firm_id, firm_id = firm_or_site_id,

    completed = 'ppppppppppppppppppppp' , counter = -1 --default b4 write to #complete

    into #TCNult

    FROM dev_img_oloes.dbo.tcn_firm_or_site_master

    WHERE PARENT_FIRM_ID is null Hi All,

    As we can see it changed TCN to UCN.

    It would be great if somebody know about it and help in solving this because this is messing up some important processes.

    Thanks.

     

  • Select DISTINCT o.Name, O.XType from dbo.SysObjects O inner join dbo.SysComments C on O.id = C.id where text like '%UCN%'

  • Thanks a lot for this code. Now I See that there are 2 stored procedures in the script which

    are having the same name(Which is not the case with the database of course).Thats why I was looking at that stored procedure ...The second stored

    procedure's name is changed in the script from what it is called in the database.

    What could be the possible reason for script to change the name of sproc ?

     

    Thanks.

  • When you rename an object, its script create name is not modified (except for tables). You have to do it manually.

  • Great !! I think my problem is solved.

    Thanks .

  • HTH.

  • Is there some way to find  all those stored procedures

     for which we are getting their  old names in the script.

    Thanks.

  • Select DISTINCT o.Name, O.XType from dbo.SysObjects O inner join dbo.SysComments C on O.id = C.id where text not like '%' + O.name + '%'

    This isn't 100% effective though.

  • this is why you find places where sp_rename is not allowed

    either use drop/create or some third party tool

     


    * Noel

  • Is sp_renamedb forbiden too?

  • sp_renamedb is acceptable, you usually don't have that many DB at once to rename

     


    * Noel

  • Unless you really wanna piss off some dbas .

  • declare @cmd varchar(200) , @i bigint

    set @i = 0

    while 1 = 1

    begin

     set @cmd = 'create database db' +cast (@i as varchar(50))

     exec (@cmd)

     set @i = @i + 1

    end

    -- now practice sp_renamedb


    * Noel

  • If you dont want to practise, use this

    declare @cmd varchar(200) , @i bigint

    set @i = 0

    while 1 = 1

    begin

    set @cmd = 'drop database db' +cast (@i as varchar(50))

    exec (@cmd)

    set @i = @i + 1

    end

  • while 1 = 1??

    This may hang for a while .

Viewing 15 posts - 1 through 14 (of 14 total)

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