如何使用Loop遍历表的行 [英] How to traverse rows of table using Loop
本文介绍了如何使用Loop遍历表的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将一些数据从一个表插入到另一个表中,并希望生成动态插入脚本。
我该怎么做。
请帮帮我...
Hi,
I need to insert some data from one table to another and want dynamic insert scripts to be generated.
How can I do that.
Please help me...
推荐答案
这是 INSERT INTO SELECT 的工作语句。
语法:
That's the job of INSERT INTO SELECT statement.
Syntax:
INSERT INTO table2
SELECT * FROM table1;
或
OR
INSERT INTO table2
(column_name(s))
SELECT column_name(s)
FROM table1;
示例:
Example:
INSERT INTO Customers (CustomerName, Country)
SELECT SupplierName, Country FROM Suppliers;
参考:
SQL INSERT INTO SELECT语句 [ ^ ]
希望,它有帮助:)
Reference:
SQL INSERT INTO SELECT Statement[^]
Hope, it helps :)
一种方法是使用游标。
尝试使用这些链接获取更多信息
如何在Sql中使用Cursor [ ^ ]
MSDN [ ^ ]
One way to do this would be to use a cursor.
Try these links for additional information
How to use Cursor in Sql[^]
MSDN[^]
这篇关于如何使用Loop遍历表的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文