SQL Server Finding table details (columns names and types)
This is a quick and easy way of using Linq Lambda expression to interrogate the SQL server INFORMATION_SCHEMA.COLUMNS, to get details about a given table.

Data class table
First thing is to create the database table class.
This example will contain only a Column name, data type and table name properties, but you can add how many or all the sys.database fields.




Connecting to the server
For this all you need to do is create a DataContext (I'm using DataContext, but it does not stop you using something else).
You will need to use a user, which has permissions to query the sys databases


Run the query
Now all you need to do is run the below code and you will get the database's on the server


Now how simple was that?

Created: 07/09/2017 Total Comment: 0

Comments

(Not Displayed)
Human validation
Enter 4655 number, before submitting to confirm your human
[Home] [All Blogs] [Contact] [Me]