I want to get name of all table of SQL Server database in my C# application. Is It possible? Plz tell me Solution.
In MySQL, there are two ways to find the names of all tables, either by using the "show" keyword or by query INFORMATION_SCHEMA. In the case of SQL Server or MSSQL, You can either use sys. tables or INFORMATION_SCHEMA to get all table names for a database.
To get a list of the tables in a MySQL database, use the mysql client tool to connect to the MySQL server and run the SHOW TABLES command. The optional FULL modifier will show the table type as a second output column.
In SQL Server, the system tables are stored per database. Hence, all is in one database, so you can just use dbname() : SELECT db_name() as DatabaseName, c.name AS ColumnName, t.name AS TableName FROM sys.
It is as simple as this:
DataTable t = _conn.GetSchema("Tables");
where _conn
is a SqlConnection object that has already been connected to the correct database.
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