Skip to content

Instantly share code, notes, and snippets.

@agrogeek
Created February 18, 2020 11:50
Show Gist options
  • Save agrogeek/60b25fea82ae65295c33c029e5535062 to your computer and use it in GitHub Desktop.
Save agrogeek/60b25fea82ae65295c33c029e5535062 to your computer and use it in GitHub Desktop.
Consulta SQL para encontrar la columna [field_name] en todas las tablas de una BD en MS SQL Server.
SELECT sysobjects.name AS table_name, syscolumns.name AS column_name,
systypes.name AS datatype, syscolumns.LENGTH AS LENGTH
FROM sysobjects INNER JOIN
syscolumns ON sysobjects.id = syscolumns.id INNER JOIN
systypes ON syscolumns.xtype = systypes.xtype
WHERE (sysobjects.xtype = 'U')
and (UPPER(syscolumns.name) like upper('%field_name%'))
ORDER BY sysobjects.name, syscolumns.colid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment