Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

T-SQL find specific user-defined table type in all stored procedures

I must delete and create a user-defined table type. This type is being used in different stored procedures.

Is there a way to find all stored procedures where the type is in use?
So that can I be sure that I find all stored procedures.

Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I knew this actually.

select * 
from sys.table_types 
where name = 'typeLT_LiefertreueLieferant'

so I get the system_type_id, but I have no way to the components in the stored procedure.

>Solution :

Below T-SQL might work for you:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION, ROUTINE_TYPE 
FROM INFORMATION_SCHEMA.ROUTINES as ISR
WHERE ROUTINE_DEFINITION LIKE '%typeLT_LiefertreueLieferant%' AND ROUTINE_TYPE='PROCEDURE' 
order by ROUTINE_DEFINITION

And If wanted to check for all table type then below T-SQL will help:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION, ROUTINE_TYPE 
FROM INFORMATION_SCHEMA.ROUTINES as ISR
cross join sys.table_types  TY
WHERE ROUTINE_DEFINITION LIKE '%'+ TY.name +'%' AND ROUTINE_TYPE='PROCEDURE' 
order by ROUTINE_DEFINITION
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading