1.表中有自增字段xh
select max(xh) from tablename
update tablename set memo='%s' where xh='%s'
2.表中有不自增的主键id
delete from tablename where id='%s'
select 999999999 as 'id'
3.SQL server里面会用到的语句
CDC数据抽取模式:
exec dbo.usp_cdc_pacs %执行存储过程
update CM_GXRQ_MANAGEMENT set max_gxrq_cdc=0x0000000000000002 where tablename='RIS_RESULT'%解决的问题:为过程或函数 cdc.fn_cdc_get_net_changes_ ... 提供的参数数目不足
时间戳模式和字典模式:(部分程序来源,数据抽取包)
if exists (select 1
from sysobjects
where id = object_id('tablename_LS')
and type = 'U')
drop table BQ_BRCWXXK_LS
go
CREATE TABLE [dbo].[tablename_LS](
[ziduan1] [varchar](20) NOT NULL,
[ziduan2] [numeric](12, 0) NULL,
[ziduan3] [numeric](9, 0) NOT NULL,
) %建立数据仓库临时表
select ?= [max_gxrq],?=[end_gxrq] from CM_GXRQ_MANAGEMENTwhere tablename =? and yljgdm=? and sys_id=? %获取更新时间
SELECT [xh] ,[memo] ,[ylxzdm] ,[fzrysdm] ,[timetemp] FROM [BQ_BRCWXXK]where convert(bigint,[timetemp]) >? and convert(bigint,[timetemp])<? %利用timetemp字段确定数据是否被抽取
4.当数据为视图模式时
数据为视图模式,分两种情况(在此处的应用),一是单张表的视图映射,二是多张表的视图映射。利用语句
sp_helptext tablename可以查看视图的组成,它是从哪几张表映射过来的。