コード例 #1
0
ファイル: BatchScripter.cs プロジェクト: Eisai/pragmasql
        private SFC.Urn[] PrepareObjectUrns(IList <DbObjectList.DbObjectInfo> objects)
        {
            SFC.Urn[] urns = new SFC.Urn[objects.Count];
            DbObjectList.DbObjectInfo objInfo = null;
            string urnTemplate = "Server[@Name='{0}']/Database[@Name='{1}']/{2}[@Name='{3}' and @Schema='{4}']";            ///Schema[@Name='{4}']";

            for (int i = 0; i < objects.Count; i++)
            {
                objInfo = objects[i];
                urns[i] = new SFC.Urn(String.Format(urnTemplate, sqlConn.TrueName, _connParams.Database, objInfo.ObjType, objInfo.Name, objInfo.Owner));
            }
            return(urns);
        }
コード例 #2
0
        private static void WriteScriptToFile(string fullFileName, Microsoft.SqlServer.Management.Sdk.Sfc.Urn schemaObject, ref Scripter scripter)
        {
            StringBuilder script = new StringBuilder();

            // Add script to file content
            foreach (string scriptLine in scripter.EnumScript(new Urn[] { schemaObject }))
            {
                string line = scriptLine;
                if (!line.Contains("SET ANSI_NULLS ON") &&
                    !line.Contains("SET ANSI_NULLS OFF") &&
                    !line.Contains("SET QUOTED_IDENTIFIER ON") &&
                    !line.Contains("SET QUOTED_IDENTIFIER OFF")
                    )
                {
                    script.AppendLine(line);
                }
            }

            using (StreamWriter sw = new StreamWriter(fullFileName, false))
            {
                sw.Write(script.ToString());
            }
        }