表结构如下:
CREATE TABLE Sync_Bas_Customer(
[fSyncID] [int] IDENTITY (1, 1) NOT NULL ,
[fChangeType] [smallint] NOT NULL ,
[fOrgID] [int] NOT NULL ,
[fSyncLogID] [uniqueidentifier] NULL ,
[fSync_fCustID] [int] NOT NULL
) ON [PRIMARY]
//测试代码
int i = 0;
while (i++ < 10)
{
SqlHelper.ExecuteNonQuery(trans, CommandType.Text,
"Insert into Sync_Bas_Customer with(tablock)(fChangeType,fOrgID,fSync_fCustID)" +
"Values(0,1,"+this.textBox1.Text+")");
System.Threading.Thread.Sleep(500);
}
//测试结论
如果不使用with(tablock)则并发执行时将不会按顺序生成数据