/// <summary> /// 创建储存过程 /// </summary> /// <param name="temp"></param> public static void CreateProc(Temp temp) { var DropPeoc = string.Format(@"DROP PROCEDURE {0}", temp.ProcName); H3DBHelper.ExecuteNonQuery(DropPeoc); if (temp.ProCols.Count > 0) { //创建存储过程 var CreateProc = string.Format(@"CREATE PROCEDURE {0} ( @TempTable {1} Readonly ) AS BEGIN SET NOCOUNT ON BEGIN TRANSACTION DELETE FROM {2}; INSERT INTO {2} ({3}) SELECT {3} FROM @TempTable COMMIT TRANSACTION END" , temp.ProcName , temp.TypeName , temp.TableName , string.Join(",\n", temp.ProCols.ToArray())); H3DBHelper.ExecuteNonQuery(CreateProc); } }
/// <summary> /// 创建数据类型 /// </summary> /// <param name="temp"></param> public static void CreateType(Temp temp) { var DropType = string.Format(@"DROP TYPE {0}", temp.TypeName); H3DBHelper.ExecuteNonQuery(DropType); var createtype = string.Format(@"CREATE TYPE {0} AS TABLE({1})" , temp.TypeName , string.Join(",\n", temp.TypeCols.ToArray())); H3DBHelper.ExecuteNonQuery(createtype); }
/// <summary> /// 创建表 /// </summary> /// <param name="temp"></param> public static void CreateTable(Temp temp) { //在10版本中创建自定义Table var DropTable = string.Format(@"DROP Table {0}", temp.TableName); H3DBHelper.ExecuteNonQuery(DropTable); var CreateTable = string.Format(@"CREATE TABLE {0} ( {1} )" , temp.TableName , string.Join(",\n", temp.TypeCols.ToArray())); H3DBHelper.ExecuteNonQuery(CreateTable); }