February 12, 2016 at 10:25 am
Hi SSC,
Is there a deterministic way to tell all the procedures which reference a certain table type? Basically, since you can't alter table types or even drop them while referenced, I have to do some sneaky rename logic, and use sp_refreshsqlmodule on the procs.
I can get close with simple pattern matching, and looking at sys.parameters, but that won't deterministically catch all references INSIDE procs. Clearly under the covers SQL is doing that check, or it wouldn't yell at me, but do you know of a sql statement I can run to do that?
February 12, 2016 at 10:34 am
The most reliable way I have found is to use the free tool Redgate SQL Search[/url]
MM
select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);
February 12, 2016 at 10:42 am
February 12, 2016 at 11:14 am
You could use a wild card search on the definition column of sys.sql_module.
February 12, 2016 at 11:39 am
Yeah, I actually mentioned that approach, but it's not always possible to get JUST those with those procs. If you had a TT called MyTableOfDoom and a presentation table called MyTableOfDoomAndTacos, the latter would match as well. I guess it wouldn't be the end of the world to refresh unnecessary procs, but I'd rather know exactly.
February 12, 2016 at 12:58 pm
I would think sys.sql_expression_dependencies would contain those references, since a table-type is in sys.objects, type = 'tt'.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
February 12, 2016 at 1:01 pm
ScottPletcher (2/12/2016)
I would think sys.sql_expression_dependencies would contain those references, since a table-type is in sys.objects, type = 'tt'.
Only way to know for sure is test it out. I may do that later if I have time.
February 12, 2016 at 1:05 pm
February 12, 2016 at 1:51 pm
Having that issue right now, the problem comes not when the type is in the code, but when it's a parameter. An easy way to find problems would be like this:
SELECT pro.name
FROM sys.parameters par
JOIN sys.procedures pro ON par.OBJECT_ID = pro.object_id
JOIN sys.types typ ON par.user_type_id = typ.user_type_id
WHERE typ.name = 'TableTypeName'
February 12, 2016 at 3:17 pm
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply