[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Querying SYSObjects to rename SP code

Posted on 2006-10-28
4
Medium Priority
?
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 252 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 248 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

649 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