Ejemplo n.º 1
0
        protected void ScriptSprocs()
        {
            foreach (string sprocName in exportParams.SprocsToScript)
            {
                // export current sproc
                SqlStoredProcedure sproc = database.StoredProcedures[sprocName];
                if (sproc == null)
                {
                    string msg = string.Format(
                        "Cannot find the stored procedure {0} in the database {1}",
                        sprocName, database.Name);
                    throw new SqlExporterException(msg);
                }

                // get sproc script
                string sql = sproc.Script(
                    SqlScriptType.Create |
                    SqlScriptType.Drop |
                    SqlScriptType.Comments |
                    SqlScriptType.Permissions);

                writer.WriteSprocScript(sproc.Name, sql);
                UpdateProgress(sproc.Name);
            }
        }
Ejemplo n.º 2
0
        protected void ScriptSproc(IProcedure sproc, IScriptWriter writer)
        {
            Throw.If(sproc, "sproc").IsNull();
            Throw.If(writer, "writer").IsNull();

            string name = DbObjectName.CreateDbObjectName(sproc);

            string msg = string.Format("Scripting stored procedure {0}", name);

            messageManager.OnScriptMessage(msg);

            SqlScript script = scriptBuilder.Create(sproc);

            writer.WriteSprocScript(name, script.ToScript());
        }