Reputation: 673
Im using c# .net windows form application. i have a SQL database with 5 tables. i need to populate a combobox with these table names. only names should be displayed.
Upvotes: 0
Views: 983
Reputation: 3544
From MSDN.
SELECT name FROM sys.tables;
Works for SQL Server 2005 and above.
Upvotes: 1
Reputation: 65166
Can't know for sure until you specify what you're using, but this is a more or less standard query for retrieving the table names (excluding views) in the current database:
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
Upvotes: 1