update 表 set a=@a where 主键=@主键 if @a>10 update 表 set b=2 where 主键=@主键 else update 表 set b=1 where 主键=@主键
perfwell(我就是我) 你这样写不是只能处理一条,呵呵
update tablename set b=case when a<10 then 1 when a>10 then 2 end
1. update tablename set b=case when a<10 then 1 when a>10 then 2 end 2.导入foxpro表 insert into 表 select * from openrowset('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\', 'select * from [aa.DBF]')
--2.导入foxpro表insert into b..bbb select * from openrowset('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\', 'select * from [aaa.DBF]')
要调整的部分说明: insert into b..bbb --b..bbb ,b为SQL的数据库名,bb为接收数据导入的表名 SourceDB=c:\ --c:\ 是dbf文件的存放目录 select * from [aaa.DBF] --aaa.dbf是dbf的文件名
/* 1问 能不能让表自动更改的,就是每当表中的字段a有变化时,字段b就会自己变可以通过触发器来进行处理: */ create trigger t_update on 你的表 AFTER insert,update as if update(a) update 你的表 set b=case when a<10 then 1 when a>10 then 2 end where a in(select a from inserted)go
update tablename set b=case when a<10 then 1 when a>10 then 2 end
我感觉还是用触发器比较好呀,就是 declare @a int select @a=a from inserted if @a>10 update 表 set b=2 where else update 表set b=1 where
set a=@a where 主键=@主键
if @a>10
update 表 set b=2 where 主键=@主键
else
update 表 set b=1 where 主键=@主键
你这样写不是只能处理一条,呵呵
set b=case when a<10 then 1 when a>10 then 2 end
update tablename
set b=case when a<10 then 1 when a>10 then 2 end
2.导入foxpro表
insert into 表
select * from
openrowset('MSDASQL',
'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\',
'select * from [aa.DBF]')
1问
能不能让表自动更改的,就是每当表中的字段a有变化时,字段b就会自己变
2问
请问 'MSDASQL',还有 [aa.dbf] 都是对应的什么,
例如,我想把 自由表aaa.dbf
导入到 sql里b数据库中的表bbb中,应该怎么写呀?
我在这之前是用程序编写的导入,但是总是有一些错误,例如
对于foxpro 中的自由表中的备注型字段,我一导入就出错,而且导入以后还存在一些字符,如#,用你说的方法导入能解决这个问题吗?
select * from
openrowset('MSDASQL',
'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\',
'select * from [aaa.DBF]')
insert into b..bbb --b..bbb ,b为SQL的数据库名,bb为接收数据导入的表名
SourceDB=c:\ --c:\ 是dbf文件的存放目录
select * from [aaa.DBF] --aaa.dbf是dbf的文件名
1问
能不能让表自动更改的,就是每当表中的字段a有变化时,字段b就会自己变可以通过触发器来进行处理:
*/
create trigger t_update on 你的表
AFTER insert,update
as
if update(a)
update 你的表
set b=case when a<10 then 1 when a>10 then 2 end
where a in(select a from inserted)go
set b=case when a<10 then 1 when a>10 then 2 end
declare @a int
select @a=a from inserted
if @a>10
update 表 set b=2 where
else
update 表set b=1 where
在case 中有没有else 可以用呢?
如果没有,想要有这种功能应该怎么写这个程序呢?
case when 1=1 then 1 else 0 end
这种情况下只能是在插入或修改表之后再用update把表再修改一次了!
MSSQLSERVER在6.5就可以使用TRIGGER了。try:
update 表
set b= case when a<10 then 1 else 0 end