马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
比较两条记录中那些字段不相等,即某个字段的值是否有改变! 例子如下: select nGoodsID, sGoodsDesc, sGoodsName, sSpec , sBrand , nPack , sUnit ,nCaseUnits , nCategoryID ,sHome ,sNationID , sNation ,sGoodsLevelID ,sGoodsLevel , sGoodTypeID ,sGoodType ,sTradeModeID ,sTradeMode ,sDepositTypeID , sDepositType , nMinLineUnit ,nMinLineL ,nShelfLife ,nMinDueDay ,sNote ,nLength ,nWidth , nHeight ,nWeight ,nCaseLength ,nCaseWidth ,nCaseHeight ,nCaseWeight , dBeginUseDate ,dEndUseDate ,sMemo1 ,sMemo2 ,sMemo3 ,sMemo4 ,sMemo5 , nLineSize ,nSafeStockDay ,nOPLM ,sOrderModeID ,sOrderMode , nSalePrice , nVipPrice,nSaleTaxRate , sMainBarcode ,nTag ,sChangeUser ,dChangeDate ,dLastUpdateTime into #Goods001 from tGoods where nGoodsID = 211 select nGoodsID, sGoodsDesc, sGoodsName, sSpec , sBrand , nPack , sUnit ,nCaseUnits , nCategoryID ,sHome ,sNationID , sNation ,sGoodsLevelID ,sGoodsLevel , sGoodTypeID ,sGoodType ,sTradeModeID ,sTradeMode ,sDepositTypeID , sDepositType , nMinLineUnit ,nMinLineL ,nShelfLife ,nMinDueDay ,sNote ,nLength ,nWidth , nHeight ,nWeight ,nCaseLength ,nCaseWidth ,nCaseHeight ,nCaseWeight , dBeginUseDate ,dEndUseDate ,sMemo1 ,sMemo2 ,sMemo3 ,sMemo4 ,sMemo5 , nLineSize ,nSafeStockDay ,nOPLM ,sOrderModeID ,sOrderMode , nSalePrice , nVipPrice,nSaleTaxRate , sMainBarcode ,nTag ,sChangeUser ,dChangeDate ,dLastUpdateTime into #Goods002 from tGoods where nGoodsID = 211 select id=identity(4), name ,dd = convert(varchar(255), ''),cc=convert(varchar(255), '') into #Goods003 from tempdb..syscolumns where id = object_id('#Goods001') declare @Num1 int declare @i int declare @Name varchar(20) declare @GoodsID varchar(8) select @GoodsID ='211' select @i = 1 select @Num1 = max(id) from #Goods003 while @i < @Num1+ 1 begin select @Name = name from #Goods003 where id = @i exec ( 'update #Goods003 set dd = convert(varchar(255), (select ' + @Name+ ' from #Goods001 where nGoodsID = convert(numeric(8,0) , ' + @GoodsID + ' ) ) )where name = '''+@Name+'''' ) exec ( 'update #Goods003 set cc = convert(varchar(255), (select ' + @Name+ ' from #Goods002 where nGoodsID = convert(numeric(8,0) , ' + @GoodsID + ' ) ) )where name = '''+@Name+'''' ) select @i = @i + 1 end select * from #Goods003 where dd<>cc drop table #Goods001 drop table #Goods002 drop table #Goods003 |