public CreateProcedureStatement GenerateUpdateStoredProcedure(Table table, QuoteType quoteType = QuoteType.NotQuoted) { var pkColumn = table.Indexes.SingleOrDefault(x => x.IsPrimary).Name; var columnNames = GetColumnNamesWithoutPrimaryKey(table, pkColumn); string storedProcedureName = string.Concat("Update", table.Name); var parameters = CreateProcedureParameters(table, true); var setClauses = new List <SetClause>(); string primaryKeyName = ""; foreach (var column in table.Columns) { if (column.IsPrimaryKey()) { primaryKeyName = column.Name; continue; } setClauses.Add(ScriptFactory.EqualsAssignmentSetClause( ScriptFactory.ColumnReference(column.Name, quoteType), ScriptFactory.IdentifierLiteral( CreateProcedureParameterVariableName(column), QuoteType.NotQuoted))); } StatementList statements = ScriptFactory.List( ScriptFactory.Update(ScriptFactory.UpdateSpecification(null, ScriptFactory.Where( ScriptFactory.BooleanEqualsComparison(ScriptFactory.IdentifierLiteral(primaryKeyName, quoteType), ScriptFactory.VariableReference(primaryKeyName))), CreateNamedTableReference(table, quoteType), null, null, null, setClauses))); return(ScriptFactory.CreateProcedure(false, ScriptFactory.ProcedureReference( GenerateStoredProcedureName(storedProcedureName, table, quoteType)), ScriptFactory.List( ScriptFactory.BeginEndBlock(statements)), null, null, parameters)); }