schema change to be reflected in all code of Store procedures in SQL Server 2005

  • Hi,

    I was having a default schema (i.e., dbo ) for all my tables in a Database, now i have a particular schema for all the tables in the database namely myschema.

    The problem is the Store procedures which were written for my database, for some part of the code they have used select fld1, fld2, fld3 from dbo.tblname and for few code i have written without dbo, now i need to change all the code in my store procedures, for the schema which i have created.

    Will any one please help me about this, how to go and is there any way.

    with Regards

  • You would need to pull all your code out of source control and do a search/replace and recompile the code.

  • Refer to BOL and read and understand what is in sys.comments.

    You could use

    SELECT id,colid, text FROM syscomments WHERE text LIKE '%word or phrase you are search for%' ORDER BY id, colid

    Of course you could alter the above to increase the WHERE clause in the above so as to search for multiple different words or phrases.

    You order by id and colid as a single row in syscomments will only store 4000 characters for the procedures text and then it creates an additional row or row(s) for remaining text. This procedure will not perform properly for encrypted procedures.

    List the procedure names that are located, then open them and do an ALTER PROCEDURE substituting the new terminology you will be using.

    DO NOT ATTEMPT TO DIRECTLY ALTER ANY ENTRY IN syscomments

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • On SQL 2005, rather use sys.sql_modules. There's one row per proc/view now, rather than 1 per 4000 character chunk. Makes searching through the code a little easier.

    Steve: Source Control? Isn't that wishful thinking? 😉

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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