我只是想从数据集中将数据导入数据库(Sql),但是当我尝试导入 70000 行时它有点慢。我做错了什么或错过了什么?请给我一些建议,我怎样才能做得更好?
这是我的 asp.net 代码:
ArtiDB entity = new ArtiDB();
int grid = 50;
foreach (string item_kisiler in kisiler)
{
if (item_kisiler == "")
continue;
if (Tools.isNumber(item_kisiler) == false)
continue;
else
{
string gsm1 = item_kisiler;
if (gsm1.Length > 10)
gsm1 = gsm1.Substring(1, 10);
entity.veriaktar(gsm1, gg, grid);
}
}
这是我的商店程序:
alter proc veriaktar
(
@gsm1 nvarchar(50)=null,
@userid uniqueidentifier,
@grupid int = 0
)
as
begin
Declare @AltMusID int
if not exists (select * from tbl_AltMusteriler with (updlock, rowlock, holdlock) where Gsm1=@gsm1 and UserId=@userid)
begin
insert into tbl_AltMusteriler (Gsm1,UserId)
values (@gsm1,@userid)
Set @AltMusID = scope_identity()
end
else
begin
Set @AltMusID = (select AltMusteriID from tbl_AltMusteriler with (updlock, rowlock, holdlock) where Gsm1=@gsm1 and UserId=@userid)
end
if (@grupid != 0)
begin
if not exists (select * from tbl_KisiGrup with (updlock, rowlock, holdlock) where GrupID=@grupid and AltMusteriID=@AltMusID)
begin
insert into tbl_KisiGrup values(@grupid,@AltMusID)
end
end
end
go