I need to list the name of all tables in the specific database in sybase and then filter these table name according some string in the name.
This gives current database but I can't specify specific database:
select name from sysobjects where type = 'U'
This gives more than tables, it includes trigger and stored procedure:
Select name from sysobjects
WHERE db_name()='pad_orr_db'
Does any body know how to do it and also filter the name of tables by some string in the name for example only the table with the SASSA in the name be displayed?
Use sp_tables.
sp_tables [table_name] [, table_owner]
[, table_qualifier][, table_type]
where *table_qualifier* is the name of the database.
Tables and Views
To get all tables, views, and system tables, the following Sybase system stored procedure can be executed.
exec sp_tables '%'
To filter by database for tables only, for example master:
exec sp_tables '%', '%', 'master', "'TABLE'"
To filter by database and owner / schema for tables only, for example, master and dbo:
exec sp_tables '%', 'dbo', 'master', "'TABLE'"
To return only views, replace "'TABLE'" with "'VIEW'". To return only system tables, replace "'TABLE'" with "'SYSTEM TABLE'".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With