Tuesday, February 3, 2009

Object Search in SQL 2005

Example here to select for object "dba_spaceused"

Object Search is not available in SQL 2005. Hopefully 2008 has one.

SELECT name,
CASE xtype
WHEN 'C' THEN 'CHECK constraint'
WHEN 'D' THEN 'Default or DEFAULT constraint'
WHEN 'F' THEN 'FOREIGN KEY constraint'
WHEN 'L' THEN 'Log'
WHEN 'FN' THEN 'Scalar function'
WHEN 'IF' THEN 'Inlined table-function'
WHEN 'P' THEN 'Stored procedure'
WHEN 'PK' THEN 'PRIMARY KEY constraint (type is K)'
WHEN 'RF' THEN 'Replication filter stored procedure'
WHEN 'S' THEN 'System table'
WHEN 'TF' THEN 'Table function'
WHEN 'TR' THEN 'Trigger'
WHEN 'U' THEN 'User table'
WHEN 'UQ' THEN 'UNIQUE constraint (type is K)'
WHEN 'V' THEN 'View'
WHEN 'X' THEN 'Extended stored procedure'
END as type
FROM sysobjects WHERE name LIKE '%dba_SpaceUsed%'
UNION ALL
SELECT name, 'column' FROM syscolumns WHERE name LIKE '%dba_SpaceUsed%'

(Reference: http://www.symantec.com/community/download/2568/object-seacrh-sql-2005)

No comments: