Come Luv ha detto che questa è una vecchia questione, ma ho trovato altre due soluzioni che possono essere utili.
Sto utilizzando l'oggetto di sistema sys.dm_sql_referenced_entities che trova tutti gli oggetti e le colonne di riferimento in un oggetto specificato. È possibile utilizzare la seguente query:
SELECT DISTINCT
referenced_schema_name AS SchemaName,
referenced_entity_name AS TableName,
referenced_minor_name AS ColumnName
FROM sys.dm_sql_referenced_entities ('yourrefencingobject', 'OBJECT');
GO
che dà il seguente risultato:
aspetto negativo di questo oggetto è che avrete bisogno di specificare un oggetto di riferimento.
O fare una ricerca come:
SELECT DISTINCT object_name(id)
FROM AdventureWorks2012.dbo.syscomments (nolock)
WHERE text like '%BusinessEntityID%'
che dà il seguente risultato:
Ho anche trovato il seguente SP che si potrebbe usare in this article, ma rifugio' t testato correttamente:
> DECLARE @string varchar(1000), @ShowReferences char(1)
>
> SET @string = 'Person.Person.BusinessEntityID' --> searchstring
>
> SET @ShowReferences = 'N'
> /****************************************************************************/ /*
> */ /* TITLE: sp_FindReferences */ /* */ /* DATE: 18 February, 2004 */ /* */ /* AUTHOR: WILLIAM MCEVOY */ /* */ /****************************************************************************/ /*
> */ /* DESCRIPTION: SEARCH SYSCOMMENTS FOR INPUT STRING, OUTPUT NAME OF OBJECT */ /*
> */ /****************************************************************************/ set nocount on
>
> declare @errnum int ,
> @errors char(1) ,
> @rowcnt int ,
> @output varchar(255)
>
> select @errnum = 0 ,
> @errors = 'N' ,
> @rowcnt = 0 ,
> @output = ''
>
> /****************************************************************************/ /* INPUT DATA VALIDATION
> */ /****************************************************************************/
>
>
> /****************************************************************************/ /* M A I N P R O C E S S I N G
> */ /****************************************************************************/
>
> -- Create temp table to hold results DECLARE @Results table ( Name varchar(55), Type varchar(12), DateCreated datetime,
> ProcLine varchar(4000))
>
>
> IF (@ShowReferences = 'N') BEGIN insert into @Results select
> distinct
> 'Name' = convert(varchar(55),SO.name),
> 'Type' = SO.type,
> crdate,
> ''
> from sysobjects SO
> join syscomments SC on SC.id = SO.id where SC.text like '%' + @string + '%' union select distinct
> 'Name' = convert(varchar(55),SO.name),
> 'Type' = SO.type,
> crdate,
> ''
> from sysobjects SO where SO.name like '%' + @string + '%' union select distinct
> 'Name' = convert(varchar(55),SO.name),
> 'Type' = SO.type,
> crdate,
> ''
> from sysobjects SO
> join syscolumns SC on SC.id = SO.ID where SC.name like '%' + @string + '%' order by 2,1 END ELSE BEGIN insert into @Results
> select
> 'Name' = convert(varchar(55),SO.name),
> 'Type' = SO.type,
> crdate,
> 'Proc Line' = text
> from sysobjects SO
> join syscomments SC on SC.id = SO.id where SC.text like '%' + @string + '%' union select
> 'Name' = convert(varchar(55),SO.name),
> 'Type' = SO.type,
> crdate,
> 'Proc Line' = ''
> from sysobjects SO where SO.name like '%' + @string + '%' union select
> 'Name' = convert(varchar(55),SO.name),
> 'Type' = SO.type,
> crdate,
> 'Proc Line' = ''
> from sysobjects SO
> join syscolumns SC on SC.id = SO.ID where SC.name like '%' + @string + '%' order by 2,1 END
>
> IF (@ShowReferences = 'N') BEGIN select Name,
> 'Type' = Case (Type)
> when 'P' then 'Procedure'
> when 'TR' then 'Trigger'
> when 'X' then 'Xtended Proc'
> when 'U' then 'Table'
> when 'C' then 'Check Constraint'
> when 'D' then 'Default'
> when 'F' then 'Foreign Key'
> when 'K' then 'Primary Key'
> when 'V' then 'View'
> else Type
> end,
> DateCreated
> from @Results
> order by 2,1 END ELSE BEGIN select Name,
> 'Type' = Case (Type)
> when 'P' then 'Procedure'
> when 'TR' then 'Trigger'
> when 'X' then 'Xtended Proc'
> when 'U' then 'Table'
> when 'C' then 'Check Constraint'
> when 'D' then 'Default'
> when 'F' then 'Foreign Key'
> when 'K' then 'Primary Key'
> when 'V' then 'View'
> else Type
> end,
> DateCreated,
> ProcLine
> from @Results
> order by 2,1 END
Spero che questo aiuta
si potrebbe iniziare con sys.columns –
e se permettete SQL dinamica in un proc o direttamente dall'applicazione si stilll non puoi raccogliere tutte le volte che una particolare colonna viene utilizzato. Inoltre, i pacchetti SSIS possono fare riferimento direttamente anche a una colonna. – HLGEM
Controlla qui: http://stackoverflow.com/questions/686247/how-to-find-the-list-of-stored-procedures-which-affect-a-particular-column –