Error:14_2627_1_-2146232060
SQL:
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tbProductSku') and type='U')
drop table #tbProductSku;
create table #tbProductSku
(
SKU varchar(50) primary key
)
insert into #tbProductSku
select item as SKU from CharSplitForIn('15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15904376,15904376,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15903880,15904376,15904376,15904376,15904376,15904376,15904376,15904376,15904376,15904376,15904376,15904376,15904376,15990682,15904376,15990682,15904376,15903880,15903880,15903880,15990682,15903880,15904376,15990682,15990682,15956896,15903880,15956941,15990682,15956896,15956941,15903880,15956941,15956896,15990682,15990682,15903880,15956896,15956941,15903880,15990682,15956941,15904376,15956896,15903880,15903880,15956896,15990682,15956941,15903880,15990682,15956941,15956896,15903880,15990682,15956896,15956941,15990682,15990682,15990682,15990682,15990682,15990682,15990682,15903880,15904376,15990682,15903880,15990682,15956941,15956896,15903880,15990682,15956941,15956896,15903880,15903880,15990682,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15990682,15956896,15956941,15956941,15990682,15956896,15990682,15903880,15904376,15903880,15903880,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15956896,15956941,15994365,15994396,15994365,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994396,15994396,15994365,15994365,15994365,15994396,15956896,15956941,15994365,15994396,15956896,15994396,15956941,15994365,15903880,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994365,15994396,15994396,15994365,15994365,15994396,15994396,15994365,15994396,15994365,15994396,15994365,15994365,15994396',','); SELECT p.DefaultLocalWarehouse AS WID,
rbwp.WareHouseName,
rbwp.WareHouseType,
p.SKU,
p.CustomerID
FROM RB_Product p(nolock)
inner join #tbProductSku ts
on p.SKU = ts.SKU
LEFT OUTER JOIN dbo.RB_WareHouse rbwp WITH (NOLOCK)
ON rbwp.ID = p.DefaultLocalWarehouse
AND rbwp.CustomerID = p.CustomerID
WHERE p.CustomerID=@CustomerID; drop table #tbProductSku;
PARAMS:@CustomerID = 1 ,
MESSAGE:Violation of PRIMARY KEY constraint 'PK__#tbProdu__CA1ECF0C02B8764C'. Cannot insert duplicate key in object 'dbo.#tbProductSku'. The duplicate key value is (15903880).
The statement has been terminated.
TRACE: 在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
在 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
在 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
在 System.Data.SqlClient.SqlDataReader.get_MetaData()
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
在 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
在 RB.DAL.DBOperator.Query(String SQLString, SqlCommand cmd, Int32 Times, SqlParameter[] cmdParms, Boolean IsWriteDB) 在 RB.DAL.DBOperator.toCommonTipException(SqlException ex, String sql, SqlParameter[] cmdParms)
在 RB.DAL.DBOperator.Query(String SQLString, SqlCommand cmd, Int32 Times, SqlParameter[] cmdParms, Boolean IsWriteDB)
在 RB.DALExtend.RB_ProductExtend.GetGetWarehouseInfoModels(Int32 customerID, List`1 skus)
在 PandaBuy.ERP.Web.IrobotBox.SalesAnalysis.AmazonBatchUpdateSalePrice.Save()
在 PandaBuy.ERP.Web.IrobotBox.SalesAnalysis.AmazonBatchUpdateSalePrice.Page_Load(Object sender, EventArgs e)
在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
在 System.Web.UI.Control.OnLoad(EventArgs e)
在 System.Web.UI.Control.LoadRecursive()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest()
在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
在 System.Web.UI.Page.ProcessRequest(HttpContext context)
在 ASP.irobotbox_salesanalysis_amazonbatchupdatesaleprice_aspx.ProcessRequest(HttpContext context)
在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
在 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
在 System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
在 System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
在 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
在 System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
在 System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
-------------------------------------------------------------
优化建议:
主键值重复,取消主键,可用索引代替
Listing那边的业务,找下翔宇