日期:2014-05-16 浏览次数:20570 次
----------------------------------------------------------------
-- Author :DBA_HuangZJ(发粪涂墙)
-- Date :2014-03-24 14:35:13
-- Version:
-- Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)
-- Apr 2 2010 15:48:46
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------------------------------------------
--> 测试数据[A]
if object_id('[A]') is not null drop table [A]
go
create table [A]([Fld_Type_Oid] nvarchar(2),[Fld_Type] nvarchar(4))
insert [A]
select 'A',N'添加' union all
select 'B',N'删除' union all
select 'C',N'修改'
--> 测试数据[B]
if object_id('[B]') is not null drop table [B]
go
create table [B]([Fld_Type_Oid] nvarchar(2),[Fld_Op_Oid] bigint)
insert [B]
select 'A',20140324001 union all
select 'A',20140324002
--------------生成数据--------------------------
select a.Fld_Type_Oid,CASE WHEN a.Fld_Type_Oid <>b.Fld_Type_Oid THEN NULL ELSE b.[Fld_Op_Oid] END Fld_Op_Oid
f