Create table ryzl([id] int,[gh] varchar(15))
Insert ryzl
select 1,'0015' union all
select 2,'0018'
GoCreate table qd1001pb([id] int,[card] varchar(15))
Insert qd1001pb
select 1,'0015' union all
select 2,'0018'
Go两个表通过id关联。需要写触发器,对ryzl表有操作的话相应的增加或更新、删除qd1001pb表,只是qd1001pb表名不固定,中间的“1001”代表2010年01月
,如果是2月的话,对应更新的表名要自动更改,请大侠们指教
Insert ryzl
select 1,'0015' union all
select 2,'0018'
GoCreate table qd1001pb([id] int,[card] varchar(15))
Insert qd1001pb
select 1,'0015' union all
select 2,'0018'
Go两个表通过id关联。需要写触发器,对ryzl表有操作的话相应的增加或更新、删除qd1001pb表,只是qd1001pb表名不固定,中间的“1001”代表2010年01月
,如果是2月的话,对应更新的表名要自动更改,请大侠们指教
create trigger tr_d
on ryzl
for delete
as
begin
declare @s varchar(100)
set @s = 'delete from qd'+left( convert(char(10),getdate(),12) ,4)+'pb'
exec (@s)
end
go
on ryzl
for delete
as
begin
declare @s varchar(100)
set @s = 'delete from qd'+RIGHT( convert(char(8),getdate(),112) ,4)+'pb'
exec (@s)
end
go???借用石头大哥的
on ryzl
for delete
as
begin
declare @s varchar(100)
set @s = 'delete from qd'+RIGHT( convert(char(6),getdate(),112) ,4)+'pb'
exec (@s)
end
go