1、服务模块操作的时候提示:
--备份数据服务器上面执行脚本
---产品单位
IF NOT EXISTS(SELECT 1 FROM sysobjects WHERE id = OBJECT_ID(N'CRM_ProductUnit') AND OBJECTPROPERTY(id,N'IsUserTable')=1)
BEGIN
CREATE TABLE CRM_ProductUnit(
[ID] [INT] IDENTITY PRIMARY KEY NOT NULL,
[Name] NVARCHAR(50),
[SortOrder] int default 0
)
exec(' INSERT INTO dbo.CRM_ProductUnit
( Name, SortOrder )
SELECT DISTINCT Unit,0 FROM CRM_Commodity WHERE ISNULL(Unit,'''') <> '''' ' )
exec(' UPDATE CRM_Commodity SET Unit = (SELECT ID FROM dbo.CRM_ProductUnit WHERE Name = Unit) WHERE ISNULL(Unit,'''') <> '''' ' )
END
标签:ProductUnit,Unit,crm,WHERE,ID,SELECT,CRM
From: https://www.cnblogs.com/wherehappens/p/17375962.html