Posted By

marcocs on 07/31/09


Tagged

admin Mantenimiento


Versions (?)

Buscar tablas por tipo de columnas


 / Published in: SQL
 

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

  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  

You need to login to post a comment.