//ids要插入in中的数据,sqlstr原始sql,num多少条执行一次
public static string[] CreateSQL(string[] ids, string sqlStr, int num)
{
string[] sqls = null;
StringBuilder sb = new StringBuilder();
sb.Append(sqlStr);
List<string> lt = new List<string>();
for (int i = 0; i < ids.Length; i++)
{
if (i != 0 && i % num == 0)
{
string s1 = sb.ToString();
s1 = s1.Remove(s1.Length - 1) + ")";
lt.Add(s1);
sb.Length = 0;
sb.Append(sqlStr);
sb.Append(ids + ",");
if (i == ids.Length - 1)
{
string s2 = sb.ToString();
s2 = s2.Remove(s2.Length - 1) + ")";
lt.Add(s2);
}
}
else
{
sb.Append(ids + ",");
if (i == ids.Length - 1)
{
string s = sb.ToString();
s = s.Remove(s.Length - 1) + ")";
lt.Add(s);
}
}
}
sqls = lt.ToArray();
return sqls;
}