首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

SQL2000数据库表内copy的有关问题

2012-03-09 
求助:SQL2000数据库表内copy的问题SQL2000PB9WINXP我想从一个表内找出符合条件的几行进行复制,复制后,要改

求助:SQL2000数据库表内copy的问题
SQL2000 PB9 WINXP

我想从一个表内找出符合条件的几行进行复制,复制后,要改变其中一列的值,其他列的值不变


例如复制前:
  a b c d e f g h
  1 1 1 1 1 1 1 3
  1 1 1 1 1 1 1 3
  1 1 1 1 1 1 1 1

复制h=3的行,同时更改a=2
复制后的结果:

  a b c d e f g h
  1 1 1 1 1 1 1 3
  1 1 1 1 1 1 1 3
  1 1 1 1 1 1 1 1
  2 1 1 1 1 1 1 3
  2 1 1 1 1 1 1 3
请教改如何实现呢?
我的数据库方面的知识有点弱,请高手尽量能给出代码,谢谢!!



[解决办法]
在pb代码中
int li_x=2
insert into xx(a,b,c,d,e,f,g,h)
select :li_x,b,c,d,e,f,g,h from xx
where h=3

在数据库的存储过程中
declare @myx integer
select @myx=2
insert into xx(a,b,c,d,e,f,g,h)
select @myx,b,c,d,e,f,g,h from xx
where h=3


探讨
引用:
insert into xx(a,b,c,d,e,f,g,h)
select 2,b,c,d,e,f,g,h from xx
where h=3




如果 2 是变量,怎么办呢?

热点排行