Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stored procedure dependencies in SQL Server Management Studio

Tags:

sql

sql-server

I don't know much about the MS world, but now it happens to be that I have to use SQL Server Management Studio 2008.

My problem: I have a column in a table, and I need to see all the stored procedures that may be acting on it.

I tried right-clicking and going 'View Dependencies' but that doesn't seem to be returning everything that it should be.

Questions like this one: SQL Server Dependencies have answers that offer 3 types of solutions

  1. Paid third party tools.
  2. Writing your own scripts.
  3. Exporting everything into text files and grepping them.

WTF? Am I missing something obvious? Is that actually how things work? I would imagine that this is a very common use case: you want to alter table and you want to make sure you won't break anything. Or if say you're looking at a new project with a DB for the first time and you want to see how certain columns get populated with stored procedures. Is there actually no quick and easy built-in workflow to do this?

like image 289
MrFox Avatar asked Dec 26 '22 22:12

MrFox


2 Answers

If you need to find database objects (e.g. tables, columns, triggers) by name - have a look at the FREE Red-Gate tool called SQL Search which does this - it searches your entire database for any kind of string(s).

enter image description here

enter image description here

It's a great must-have tool for any DBA or database developer - did I already mention it's absolutely FREE to use for any kind of use??

like image 106
marc_s Avatar answered Mar 04 '23 20:03

marc_s


Use this query:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION 
FROM INFORMATION_SCHEMA.ROUTINES 
WHERE ROUTINE_DEFINITION LIKE '%YOUR COLUMN %' 
AND ROUTINE_TYPE='PROCEDURE'
like image 28
Henrik Nyberg Avatar answered Mar 04 '23 21:03

Henrik Nyberg