请教 存储过程中 如何才能下移记录指针?

hxz2008 2006-02-14 07:15:41
有一表t1(id,title,content,w)和一表t2(id,title,content) 求一存储过程:如何才能把表t1中 所有w='1'的记录拷贝到 t2中?谢谢各位
...全文
121 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hxz2008 2006-02-15
  • 打赏
  • 举报
回复
感谢各位的到来
hxz2008 2006-02-15
  • 打赏
  • 举报
回复
表t1的id是标识种子 自增量 表t2中id当然不是自增量
用不用什么循环控制语句或什么指针下移等技术呢?
wgsasd311 2006-02-15
  • 打赏
  • 举报
回复
--上面第2条描述写返了
--1.表t2(id,title,content) 中ID不是自增量:
create proc T_proc
as
insert t2 select * from t1 where w='1'
--2.表t2(id,title,content) 中ID是自增量:
create proc T_proc
as
insert t2 select title,content from t1 where w='1'
wgsasd311 2006-02-15
  • 打赏
  • 举报
回复
--1.表t2(id,title,content) 中ID不是自增量:
create proc T_proc
as
insert t2 select * from t1 where w='1'
--2.表t2(id,title,content) 中ID不是自增量:
create proc T_proc
as
insert t2 select title,content from t1 where w='1'

hxz2008 2006-02-15
  • 打赏
  • 举报
回复
有一表t1(id,title,content,w)和一表t2(id,title,content) 求一存储过程:如何才能把表t1中 所有w='1'的记录拷贝到 t2中?要求每一次都让t2表中id='1'
OracleRoob 2006-02-14
  • 打赏
  • 举报
回复
create proc sp_test
as

insert into t2(id,title,content)
select id,title,content
from t1
where w='1'
go


--执行
exec sp_test
$扫地僧$ 2006-02-14
  • 打赏
  • 举报
回复
Try:

create proc T_proc
as
insert t2 select id,title,content from t1 where w='1'

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧