Identifying all stored procedures and tables using a User-Defined Data Type in T-Sql












0















I'm using SSMS and I have a User-Defined Data Type which was created in the early 2000 with a rule object attached to it.



Many tables and stored procedures use this User-Defined Data Type as a type. I want to alter these tables and stored procs to take out this UDT so I can replace them with check constraints, but I'm having trouble identifying all the tables and stored procs in which this UDT is used as a type.



I've been looking at old scripts and using sp_help table_name to seek out these instances, but I was wondering if there's a way to find all the tables/columns and stored procs which use a certain user-defined data type.



Thank you.



EDIT: I figured out how to find all the uses of user-defined data types on tables



SELECT TABLE_NAME, COLUMN_NAME, DOMAIN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DOMAIN_NAME = 'UDT_name'


For stored procedures, I removed my discovered method because NicVerAZ linked a better way to accomplish this below.










share|improve this question




















  • 1





    INFORMATION_SCHEMA.ROUTINES is not necessarily the best solution because ROUTINE_DEFINITION is limited to 4000 characters.

    – NicVerAZ
    Nov 14 '18 at 23:16











  • Ah, I didn't know that. Thanks. We definitely have some large stored procedure in our DB. I probably can't rely on that.

    – Jeff Hernandez
    Nov 14 '18 at 23:19











  • Try encapsulation. Long stored procs are not a good thing. I have seen insanely long ones which were a nightmare to work on.

    – NicVerAZ
    Nov 15 '18 at 14:43
















0















I'm using SSMS and I have a User-Defined Data Type which was created in the early 2000 with a rule object attached to it.



Many tables and stored procedures use this User-Defined Data Type as a type. I want to alter these tables and stored procs to take out this UDT so I can replace them with check constraints, but I'm having trouble identifying all the tables and stored procs in which this UDT is used as a type.



I've been looking at old scripts and using sp_help table_name to seek out these instances, but I was wondering if there's a way to find all the tables/columns and stored procs which use a certain user-defined data type.



Thank you.



EDIT: I figured out how to find all the uses of user-defined data types on tables



SELECT TABLE_NAME, COLUMN_NAME, DOMAIN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DOMAIN_NAME = 'UDT_name'


For stored procedures, I removed my discovered method because NicVerAZ linked a better way to accomplish this below.










share|improve this question




















  • 1





    INFORMATION_SCHEMA.ROUTINES is not necessarily the best solution because ROUTINE_DEFINITION is limited to 4000 characters.

    – NicVerAZ
    Nov 14 '18 at 23:16











  • Ah, I didn't know that. Thanks. We definitely have some large stored procedure in our DB. I probably can't rely on that.

    – Jeff Hernandez
    Nov 14 '18 at 23:19











  • Try encapsulation. Long stored procs are not a good thing. I have seen insanely long ones which were a nightmare to work on.

    – NicVerAZ
    Nov 15 '18 at 14:43














0












0








0








I'm using SSMS and I have a User-Defined Data Type which was created in the early 2000 with a rule object attached to it.



Many tables and stored procedures use this User-Defined Data Type as a type. I want to alter these tables and stored procs to take out this UDT so I can replace them with check constraints, but I'm having trouble identifying all the tables and stored procs in which this UDT is used as a type.



I've been looking at old scripts and using sp_help table_name to seek out these instances, but I was wondering if there's a way to find all the tables/columns and stored procs which use a certain user-defined data type.



Thank you.



EDIT: I figured out how to find all the uses of user-defined data types on tables



SELECT TABLE_NAME, COLUMN_NAME, DOMAIN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DOMAIN_NAME = 'UDT_name'


For stored procedures, I removed my discovered method because NicVerAZ linked a better way to accomplish this below.










share|improve this question
















I'm using SSMS and I have a User-Defined Data Type which was created in the early 2000 with a rule object attached to it.



Many tables and stored procedures use this User-Defined Data Type as a type. I want to alter these tables and stored procs to take out this UDT so I can replace them with check constraints, but I'm having trouble identifying all the tables and stored procs in which this UDT is used as a type.



I've been looking at old scripts and using sp_help table_name to seek out these instances, but I was wondering if there's a way to find all the tables/columns and stored procs which use a certain user-defined data type.



Thank you.



EDIT: I figured out how to find all the uses of user-defined data types on tables



SELECT TABLE_NAME, COLUMN_NAME, DOMAIN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DOMAIN_NAME = 'UDT_name'


For stored procedures, I removed my discovered method because NicVerAZ linked a better way to accomplish this below.







sql tsql user-defined-data-types






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 23:24







Jeff Hernandez

















asked Nov 14 '18 at 22:31









Jeff HernandezJeff Hernandez

256




256








  • 1





    INFORMATION_SCHEMA.ROUTINES is not necessarily the best solution because ROUTINE_DEFINITION is limited to 4000 characters.

    – NicVerAZ
    Nov 14 '18 at 23:16











  • Ah, I didn't know that. Thanks. We definitely have some large stored procedure in our DB. I probably can't rely on that.

    – Jeff Hernandez
    Nov 14 '18 at 23:19











  • Try encapsulation. Long stored procs are not a good thing. I have seen insanely long ones which were a nightmare to work on.

    – NicVerAZ
    Nov 15 '18 at 14:43














  • 1





    INFORMATION_SCHEMA.ROUTINES is not necessarily the best solution because ROUTINE_DEFINITION is limited to 4000 characters.

    – NicVerAZ
    Nov 14 '18 at 23:16











  • Ah, I didn't know that. Thanks. We definitely have some large stored procedure in our DB. I probably can't rely on that.

    – Jeff Hernandez
    Nov 14 '18 at 23:19











  • Try encapsulation. Long stored procs are not a good thing. I have seen insanely long ones which were a nightmare to work on.

    – NicVerAZ
    Nov 15 '18 at 14:43








1




1





INFORMATION_SCHEMA.ROUTINES is not necessarily the best solution because ROUTINE_DEFINITION is limited to 4000 characters.

– NicVerAZ
Nov 14 '18 at 23:16





INFORMATION_SCHEMA.ROUTINES is not necessarily the best solution because ROUTINE_DEFINITION is limited to 4000 characters.

– NicVerAZ
Nov 14 '18 at 23:16













Ah, I didn't know that. Thanks. We definitely have some large stored procedure in our DB. I probably can't rely on that.

– Jeff Hernandez
Nov 14 '18 at 23:19





Ah, I didn't know that. Thanks. We definitely have some large stored procedure in our DB. I probably can't rely on that.

– Jeff Hernandez
Nov 14 '18 at 23:19













Try encapsulation. Long stored procs are not a good thing. I have seen insanely long ones which were a nightmare to work on.

– NicVerAZ
Nov 15 '18 at 14:43





Try encapsulation. Long stored procs are not a good thing. I have seen insanely long ones which were a nightmare to work on.

– NicVerAZ
Nov 15 '18 at 14:43












1 Answer
1






active

oldest

votes


















1














Refer to the article below on how to properly search for a string in a stored procedure definition:



Search text in stored procedure in SQL Server



As I posted in a comment above, ROUTINE_DEFINITION is an NVARCHAR(4000) and longer stored procedures have their definition truncated.



Your second method is not bad, it gets it done but yes your first is more correct.






share|improve this answer
























  • Thanks. This was exactly what i needed.

    – Jeff Hernandez
    Nov 14 '18 at 23:23











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309719%2fidentifying-all-stored-procedures-and-tables-using-a-user-defined-data-type-in-t%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Refer to the article below on how to properly search for a string in a stored procedure definition:



Search text in stored procedure in SQL Server



As I posted in a comment above, ROUTINE_DEFINITION is an NVARCHAR(4000) and longer stored procedures have their definition truncated.



Your second method is not bad, it gets it done but yes your first is more correct.






share|improve this answer
























  • Thanks. This was exactly what i needed.

    – Jeff Hernandez
    Nov 14 '18 at 23:23
















1














Refer to the article below on how to properly search for a string in a stored procedure definition:



Search text in stored procedure in SQL Server



As I posted in a comment above, ROUTINE_DEFINITION is an NVARCHAR(4000) and longer stored procedures have their definition truncated.



Your second method is not bad, it gets it done but yes your first is more correct.






share|improve this answer
























  • Thanks. This was exactly what i needed.

    – Jeff Hernandez
    Nov 14 '18 at 23:23














1












1








1







Refer to the article below on how to properly search for a string in a stored procedure definition:



Search text in stored procedure in SQL Server



As I posted in a comment above, ROUTINE_DEFINITION is an NVARCHAR(4000) and longer stored procedures have their definition truncated.



Your second method is not bad, it gets it done but yes your first is more correct.






share|improve this answer













Refer to the article below on how to properly search for a string in a stored procedure definition:



Search text in stored procedure in SQL Server



As I posted in a comment above, ROUTINE_DEFINITION is an NVARCHAR(4000) and longer stored procedures have their definition truncated.



Your second method is not bad, it gets it done but yes your first is more correct.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 23:19









NicVerAZNicVerAZ

355310




355310













  • Thanks. This was exactly what i needed.

    – Jeff Hernandez
    Nov 14 '18 at 23:23



















  • Thanks. This was exactly what i needed.

    – Jeff Hernandez
    Nov 14 '18 at 23:23

















Thanks. This was exactly what i needed.

– Jeff Hernandez
Nov 14 '18 at 23:23





Thanks. This was exactly what i needed.

– Jeff Hernandez
Nov 14 '18 at 23:23




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309719%2fidentifying-all-stored-procedures-and-tables-using-a-user-defined-data-type-in-t%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

The Sandy Post

Danny Elfman

Pages that link to "Head v. Amoskeag Manufacturing Co."