如何逐行读取特定的列值 [英] How can read particular column value row by row

查看:72
本文介绍了如何逐行读取特定的列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们.
如何逐行读取列值.例如使用while条件,我想将数据插入新表中.为此,我计算了旧表中的行数.但是我想一张一张地插入旧表中的所有行到新表中,因为我只需要在每一行中做点什么.就像c#中的for循环.请参考任何方法

谢谢

Hi friends.
How can read column value row by row. for example using while condition i want to insert data to new table.For that i counted how many rows in the old table. but i want to insert all the rows from the old table to new table one by one because i just to need to do something in every row.like for loop in the c#.please refer any method

Thank you

推荐答案

如果要进行逐行操作,则应该使用CURSOR的帮助,因为游标的操作就像for循环一样.要创建光标,请尝试以下链接:-
http://blog.sqlauthority.com/2007/01/01 /sql-server-simple-example-of-cursor/ [
If you want to do Row by row operation then you should go for taking the help of a CURSOR because cursor operates just like for loop. For creating cursor try this link :-
http://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/[^]




您可以根据需要使用光标.

请参阅下面的链接,这将使您了解游标.

http://blog.sqlauthority.com/2007/01/01 /sql-server-simple-example-of-cursor/ [ http://msdn.microsoft.com/en-us/library/ms180169.aspx [ ^ ]

http://www.mssqltips.com/sqlservertip/1599/sql-server-cursor-example / [ ^ ]

谢谢,
Viprat
Hi,

You can use the cursor for your purpose.

See the below link, which will give you the idea of the Cursor.

http://blog.sqlauthority.com/2007/01/01/sql-server-simple-example-of-cursor/[^]

http://msdn.microsoft.com/en-us/library/ms180169.aspx[^]

http://www.mssqltips.com/sqlservertip/1599/sql-server-cursor-example/[^]

Thanks,
Viprat


这篇关于如何逐行读取特定的列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆