I need to get View SQL Query to display it in some text box within C# CODE level.
Each View is build upon part e.g. Select x From table and I want to retrieve it in my C# code, only that query using View name I already know.
How to achieve this in C# maybe using ADO.NET?
I need to get View SQL Query to display it in some text box
Share
Use ADO.Net
SqlDataAdapterobject’sSelectCommandproperty to get the select query associated with the dataset/datatable, assuming this is what you want…Below is the MSDN link for explanation of
SelectCommandproperty:http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.selectcommand.aspx
OK, if you want the underlying query for your
database VIEW, then as it is stored on the database server, you can only get it by executing the stored proceduresp_helptext 'YOUR_VIEW_NAME'in sql management studio or even from ADO.Net in C#/VB.Net. Refer link below:http://msdn.microsoft.com/en-us/library/ms176112.aspx