关于更新等待的问题
现在有个期间表
表结构如下
CREATE TABLE [dbo].[FsubBalance](
[periodid] [varchar](8) COLLATE Chinese_PRC_CI_AS NOT NULL,
[companyid] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
[account] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
[currency] [varchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_FsubBalance_currency] DEFAULT ('RMB'),
[cv1] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_FsubBalance_cv1] DEFAULT (''),
[cv1name] [varchar](80) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_FsubBalance_cv1name] DEFAULT (''),
[cv2] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_FsubBalance_cv2] DEFAULT (''),
[cv2name] [varchar](80) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_FsubBalance_cv2name] DEFAULT (''),
[cv3] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_FsubBalance_cv3] DEFAULT (''),
[cv3name] [varchar](80) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_FsubBalance_cv3name] DEFAULT (''),
[cv4] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_FsubBalance_cv4] DEFAULT (''),
[cv4name] [varchar](80) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_FsubBalance_cv4name] DEFAULT (''),
[cv5] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_FsubBalance_cv5] DEFAULT (''),
[cv5name] [varchar](80) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_FsubBalance_cv5name] DEFAULT (''),
[gltype] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_FsubBalance_gltype] DEFAULT ('无'),
[prebalance] [decimal](18, 2) NULL,
[natprebalance] [decimal](18, 2) NULL,
[preqty] [int] NULL,
[debit] [decimal](18, 2) NULL,
[natdebit] [decimal](18, 2) NULL,
[credit] [decimal](18, 2) NULL,
[natcredit] [decimal](18, 2) NULL,
[balance] AS ((isnull([prebalance],(0))+isnull([debit],(0)))-isnull([credit],(0))),
[natbalance] AS ((isnull([natprebalance],(0))+isnull([natdebit],(0)))-isnull([natcredit],(0))),
[qty] [int] NULL,
[debit_qty] [int] NULL,
[credit_qty] [int] NULL,
[keyid] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
CONSTRAINT [PK_FsubBalance] PRIMARY KEY NONCLUSTERED
(
[keyid] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
update fsubbalance set credit=isnull(credit,0)+isnull(@money,0),
natcredit=isnull(natcredit,0)+isnull(@natmoney,0),
credit_qty=isnull(credit_qty,0)+isnull(@qty,0)
where companyid=@companyid
and periodid=@periodid
and cv1=isnull(@cv1,'')
and cv2=isnull(@cv2,'')
and currency=isnull(@currency,'')
and account=@account
[解决办法]
1、执行计划贴出来看看。
2、更新的数据量大吗?