Retrieve result columns from StoredProc without executing it using Microsoft.SqlServer.Management.Smo

I want to get a list of result sets and columns that I can expect from SP. I was able to get the parameters, script ... but I don't know where to find the result sets and column names.

using Microsoft.SqlServer.Management.Smo;

using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mydbconn"].ConnectionString))
        {
            conn.Open();
            Server sv = new Server(new Microsoft.SqlServer.Management.Common.ServerConnection(conn));
            Database db = sv.Databases["mydb"];

            foreach (StoredProcedure sp in db.StoredProcedures)
            {
                string[] columns = sp.??????
            }

        }

Is there any way to get the columns? I end up trying to write a code generator to automate my write data access objects. Thank you SO!

EDIT: "Another solution - if you can get the value of ScalarResult, you can convert it to something useful, from which you can get the columns" .: Any ideas how to do this?

+3
source share
3

. , SET FMTONLY ON, (.. - , ). (, ).

, SELECT , SET FMTONLY ON, , , .

(UDF) , .

+6

StoredProcedure (http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.storedprocedure_members.aspx) MSDN .

-, GetTextBody script . - . , ( , ), . , , 100%... .

- ScalarResult, - , .

: SP, . ( ) "", .

+2

, . Visual Studio 11 SMO .

StoredProcedure SMO "".

MSDN:

StoredProcedureParameterCollection. StoredProcedureParameter , .

MSDN

Gagan

0

All Articles