Solved

Querying SYSObjects to rename SP code

Posted on 2006-10-28
4
402 Views
Last Modified: 2008-02-01
I have over 200 stored procedures in my database and about 90 tables.  I have renamed some of the schemas and tables, so I have to change code in about 90% or more of the stored procedures.  I have done about 20 so far, and I am beat... is it possible to query sysobjects for code, or table references inside of the stored procedures?

for example, if I have a stored procedure with this code (select * from [Inventory].tbl_Inventory) and I change it to (select * from [Inventory].Products) how can I automate this?  I want to search all stored procedures with have the tbl_Inventory and replace it with tbl_Products.  Is this possible?

Thank you,

StankStank
0
Comment
Question by:stankstank
4 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 63 total points
ID: 17828243
extract all your stored procedure to a single file (use the gererate sql option  from right click on data base ... all tasks...)


then in Query analyser use search and replace (from edit) to convert your code...

then reapply the stored procedures

and test test test....

hope you're doing this in a test / development database...
0
 
LVL 29

Assisted Solution

by:Nightman
Nightman earned 62 total points
ID: 17828960
Quickly identify consuming objects (will return views, functions, stored procs, etc)
SELECT
  so.name,
  so.id,
  so.xtype
FROM
  sysobjects so
INNER JOIN syscomments sc ON  sc.id=so.id
AND sc.text LIKE '%tbl_Inventory%'

Won't automatically apply. And like Lowfatspread said - test!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question