1.如何同步根据部门表同步另外一个项目表的部门字段
update A set A.auditownerid=(select lp.epleaderId
from (select ep.userid as epuserid,adp.leaderId as epleaderId from B ep left join DP adp
on adp.arcid=ep.departmentid) lp where A.ownerid=lp.epuserid)
2.同步一列数据等于另一列数据
update [dbo].[InvoiceTab] set ActualInvoiceMoney=InvoiceMoneyAmount where invoicestatus=6 and isdeleted=0
3.根据一列表中数据,同步生成另一个表数据
insert into [dbo].[InvoiceTabDetails]
select newid(),invoiceId,projectId,ownerid,invoicenumber,invoiceMoneyAmount,ownerid,UpdateOperatorId,'',1,0,invoiceRaiseDate
,actualPayDate,actualPayDate,PayMoney,invoiceRaiseDate
from (select ic.invoiceId,ic.projectId,ic.invoicenumber,pro.ownerid,ic.invoiceRaiseDate,ic.actualPayDate,
ic.invoiceMoneyAmount,ic.PayMoney,ic.isdeleted,ic.updatetime,ic.UpdateOperatorId
from invoicetab ic left join projecttab pro on ic.projectid = pro.projectid
where ic.invoicestatus=6 and ic.actualPayDate is not null and ic.isdeleted=0 ) InvocieData
4.添加字段-修改字段名称-删除约束和字段
1.ALTER TABLE DailyWorkServiceDetail ADD DifferenceProportion float default 0.0 not null
2.sp_rename 'DailyWorkServiceSummary.AllProjecMoney','AllProjectMoney'
3.alter table DailyWorkServiceSummary drop column ProjecStatisticData
alter table ProjectPhone drop constraint DF__ProjectPh__Diffe__03A67F89