Buscar tablas por tipo de columnas


/ Published in: SQL
Save to your folder(s)

Buscar tablas por tipo de columnas;
Note:AND OBJECT_NAME(object_id) NOT LIKE 'sy%': cuidado si tienes tablas que empiezan con "sy%"


Copy this code and paste it in your HTML
  1. USE MYDB
  2. GO
  3.  
  4. DECLARE @VALUE NVARCHAR(128);
  5. SELECT @VALUE = 'text'; -- Tipo a buscar
  6.  
  7. SELECT OBJECT_NAME(object_id) AS object_name,
  8. c.name AS column_name,
  9. TYPE_NAME(c.user_type_id) AS user_type_name,
  10. c.max_length
  11. FROM sys.columns AS c
  12. INNER JOIN sys.types AS t ON c.user_type_id = t.user_type_id
  13. WHERE c.user_type_id = TYPE_ID('text') AND OBJECT_NAME(object_id) NOT LIKE 'sy%'

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.