ADO.Net : Get table definition from SQL server tables

后端 未结 5 577
梦毁少年i
梦毁少年i 2021-01-12 20:37

I am using C# to write a method that returns the following information about a table: column names, column types, column sizes, foreign keys.

Can someone point me in

5条回答
  •  梦毁少年i
    2021-01-12 21:01

    This really depends on how you communicate with your database. If you are using LinqToSQL or another similar ORM this would be pretty easy but if you want to get these values via a query I'd suggest you use the INFORMATION_SCHEMA views as these are fast and easy to query.

    e.g.

    select * from information_schema.columns where table_name = 'mytable'
    

提交回复
热议问题