SQL help - find the table that has 'somefieldId' as the primary key?
- by Kettenbach
Hello All,
How can I search my sql database for a table that contains a field 'tiEntityId'. This field is referenced in a stored procedure, but I am unable to identify which table this id is a primary key for? Any suggestions? I currently look through stored procedure definitions for references to text by using something like this
Declare @Search varchar(255)
SET @Search='[10.10.100.50]'
SELECT DISTINCT
o.name AS Object_Name,o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%'+@Search+'%'
ORDER BY 2,1
Any SQL guru's out there know what I need to use to find the table that contains the field, 'preferably the table where that field is the Primary Key.
Thanks so much for any tips.
Cheers,
~ck in San Diego