User Tools

Site Tools


sybase_sql_snippets

Sybase SQL Snippets

Get Info from SysObjects

SELECT   *
FROM     sysobjects
WHERE    1 = 1
--AND      sysobjects.type = 'U' -- user table
--AND      sysobjects.type = 'V' -- view
--AND      sysobjects.type = 'L' -- log
--AND      sysobjects.type = 'P' -- procedure
--AND      sysobjects.type = 'R' -- rule
--AND      sysobjects.type = 'D' -- default
--AND      sysobjects.type = 'TR' -- trigger
--AND      sysobjects.type = 'RI' -- referential constraint 
ORDER BY sysobjects.name

Show Columns In A Table

SELECT   syscolumns.name
         , *
FROM     syscolumns
JOIN     sysobjects ON syscolumns.id = sysobjects.id
WHERE    sysobjects.name = 'TABLE_NAME'
ORDER BY syscolumns.name

Search All Column Names

SELECT   sysobjects.name
         , syscolumns.name
         , *
FROM     syscolumns
JOIN     sysobjects ON syscolumns.id = sysobjects.id
WHERE    syscolumns.name LIKE '%directive_id%'
ORDER BY sysobjects.name ASC
         , syscolumns.name ASC
sybase_sql_snippets.txt · Last modified: 2016/12/31 19:05 (external edit)