Solved

Querying SYSObjects to rename SP code

Posted on 2006-10-28
4
404 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 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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.

688 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