473,499 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding Stored Procs that Ref/Update a column

Could any suggest to me a good way to programmatically identify which SPs
update a database column. I would like to create a cross reference for our
database.
Jul 23 '05 #1
5 2145

"Chad" <ch**************@unisys.com> wrote in message
news:cs**********@trsvr.tr.unisys.com...
Could any suggest to me a good way to programmatically identify which SPs
update a database column. I would like to create a cross reference for our
database.


Check out sp_depends and sysdepends in Books Online. Unfortunately, there is
no entirely accurate way to get this information in MSSQL, because of things
like deferred name resolution (you can create a proc referencing a table
which doesn't exist) and dynamic SQL (the column name may not even be in the
proc). But depending on the size and complexity of your database, sp_depends
might be good enough.

Simon
Jul 23 '05 #2
Thanks for the response.

Sp_depends seems to tell me what SPs reference a table or view.

I am trying to determine which SPs update a COLUMN in a table.

Any suggestions.

"Simon Hayes" <sq*@hayes.ch> wrote in message
news:41********@news.bluewin.ch...

"Chad" <ch**************@unisys.com> wrote in message
news:cs**********@trsvr.tr.unisys.com...
Could any suggest to me a good way to programmatically identify which SPs
update a database column. I would like to create a cross reference for
our database.


Check out sp_depends and sysdepends in Books Online. Unfortunately, there
is no entirely accurate way to get this information in MSSQL, because of
things like deferred name resolution (you can create a proc referencing a
table which doesn't exist) and dynamic SQL (the column name may not even
be in the proc). But depending on the size and complexity of your
database, sp_depends might be good enough.

Simon

Jul 23 '05 #3
If you know the tables that the proc references then you can scroll
thru the tables to find if you see a match on the columns...

Loop thru each table thats been referenced...

If exists (Your column name) IN (select name from syscolumns where id =
object_id('TheTableName'))
Print "Bingo!!!!.. Found column"
Else
Pring "Try harder"

Jul 23 '05 #4

"Chad" <ch**************@unisys.com> wrote in message
news:cs**********@trsvr.tr.unisys.com...
Thanks for the response.

Sp_depends seems to tell me what SPs reference a table or view.

I am trying to determine which SPs update a COLUMN in a table.

Any suggestions.


<snip>

You can execute sp_depends twice, first with the table name to find out
which procs update it, then with the proc names to find the updated columns:

create table dbo.t1 (col1 int, col2 int)
go
create proc dbo.p1
as update dbo.t1 set col1 = 2
go
create proc dbo.p2
as update dbo.t1 set col2 = 3
go

-- Get the proc names
exec sp_depends 't1'
go

-- Get the details of what each proc updates
exec sp_depends 'p1'
go
exec sp_depends 'p2'
go

drop table dbo.t1
drop proc dbo.p1
drop proc dbo.p2
go
Simon
Jul 23 '05 #5
Chad (ch**************@unisys.com) writes:
Thanks for the response.

Sp_depends seems to tell me what SPs reference a table or view.

I am trying to determine which SPs update a COLUMN in a table.


Have a closer look on sysdepends table. Here is a sample:

SELECT o.name, o2.name, c.name
FROM sysobejcts o
JOIN sysdepends d ON o.id = d.id
JOIN sysobjects o2 ON d.depid = o.id
JOIN syscolumns c ON d.depid = c.id
AND d.depnumber = c.colid
WHERE o2.name in ('this_table', 'that_table')
AND d.resultobj = 1
ORDER BY o.name, o2.name, c.name

Note that resultobj could also refer to an INSERT statement.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7763
by: rnewman | last post by:
I have a task to where I need to move a column from one table to another. I want to be sure I update any view, stored procedure, trigger, etc. that references the column. I simply want a query that...
1
460
by: LineVoltageHalogen | last post by:
Greetings All, currentley there is a heated discussion in my place of work over which method is better/more efficient for simple selects. Background: 1.) Simple Application that uses sql server...
4
13456
by: marc | last post by:
I've been developing a stored procedure that uses a user defined function in the query portion of the procedure. However, since the end product needs to allow for dynamic table names, the UDF will...
4
16677
by: shalini | last post by:
All, we are trying to create and execute our stored procs on db2 ver 8.1 fp5. This is a new database that we setup and are having some trouble. When I try and run the stored proc from the db2...
16
2084
by: efiryago | last post by:
Since V8.2 does not require a C compiler to build SQL stored procedures, I am just wonderring how they are now implemented internaly as opposed to C embedded SQL before V8.2, so, basicaly, what...
45
3358
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
15
2255
by: Burt | last post by:
I'm a stored proc guy, but a lot of people at my company use inline sql in their apps, sometimes putting the sql in a text file, sometimes hardcoding it. They don't see much benefit from procs, and...
2
1766
by: Andy B | last post by:
Is there an easy way to convert tableAdaptor queries into stored procs without messing up the dataTables in the dataSet or losing the queries themselves?
5
4054
by: Bogdan | last post by:
Hi, I have a stored procedure that uses JOINs to return columns from multiple tables. I also have another stored proc that that takes a series of params and updates multiple tables. I used the...
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.