행을 업데이트/삽입하기 위해 텍스트 파일을 읽는 프로그램이 있습니다. 나는 아래의 다음 의사 코드 방법을 시도했다. 이것들은 모두 매우 느립니다. 이 코드는 SQL Server에서 직접 실행되며이 프로세스는 모두 완료하는 데 많은 시간이 걸립니다 ...SQL Server에서 수백만 행을 가장 효율적으로 삽입/업데이트하는 방법은 무엇입니까?
업데이트/삽입 문은 수백만 개 정도의 어딘가에 있습니다. .net C#에서 그 많은 SQL 문을 실행하는 가장 효율적인 방법은 무엇입니까?
// Insert/Update while reading text file
While (reader.read)
{
sql.ExecuteNonQuery();
}
또는 ...
// build a list to loop through later and insert/update
While (reader.read)
{
List.Add(sql);
}
foreach(string s in sql)
{
sql.ExecuteNonQuery();
}
또는 ...
// Build a list and run 1000 statements at one time
While (reader.read)
{
List.Add(sql);
if(List.Count == 1000)
{
sql.ExecuteNonQuery();
}
}
그것은 꽤 간단하고 신속하고도 효율적으로 – MethodMan