var reader = new SqlCommand("Select * from sys.columns", MyCon).ExecuteReader();
This shows this strange output
What I want is to get the columns values (nvarchar, varchar and so on...) from the database table as a string.
This query is not working in SQL Server I tried it
Show Columns From MyTable
it shows
System.Data.SqlClient.SqlException: 'Incorrect syntax near the keyword 'From'.'
Start checking this query:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
You can access the data that you want to in this view.
Table name, column name, data type... It's all there.
This is the doc from MS, about the information_schema views:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.