sybasesap-ase

How do I select current database name and all the schema for the database name in SYBASE ASE using a query


How do I select current database name and all the schema for the database name in SYBASE ASE using a query

tried Select db_name

gives invalid column name


Solution

  • Current database:

    select db_name()
    

    By 'schema' I'm assuming you mean a user (in the database) who owns at least one object:

    select distinct(user_name(uid)) from sysobjects
    

    NOTE: I'm not sitting in front of an ASE instance at the moment so can't recall, or verify, if the 2nd query could generate a NULL ... should be easy enough to test and add an optional where clause to filter out as needed