为什么我们在传递table作为参数时使用select命令? [英] why we are using select command when we passing table as parameter?
本文介绍了为什么我们在传递table作为参数时使用select命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑这个存储的大量插入程序......
CREATE PROCEDURE SP_PERDRAWT
@ tblperdraw createtype_perdraw READONLY
AS
BEGIN
SET NOCOUNT ON
INSERT INTO mytable(姓名,地址,年龄)
SELECT * FROM @ tblperdraw
END
这里为什么我们是使用select命令?如何连接TABLE-> TABLE TYPE-> STORED PROCEDURE?
请给我一个breif
解决方案
在您的示例中,SELECT子句提供了从表变量到INSERT的多行。这意味着如果例如表变量包含5行,那么将插入5行。
SELECT可以来自变量,来自视图,实际表等等。
欲了解更多信息,请查看 INSERT(Transact-SQL) [ ^ ]
CONSIDER THIS STORED PROCEDURE FOR BULK INSERTION...
CREATE PROCEDURE SP_PERDRAWT
@tblperdraw createtype_perdraw READONLY
AS
BEGIN
SET NOCOUNT ON
INSERT INTO mytable(name,address ,age)
SELECT * FROM @tblperdraw
END
here why we are using select command? how it is connected with TABLE->TABLE TYPE->STORED PROCEDURE?
pls give me a breif
解决方案
In your example the SELECT clause is providing several rows from a table variable to the INSERT. That means that if for example the table variable contains 5 rows, then 5 rows will be inserted.
The SELECT can be from a variable, from a view, actual table and so on.
For more information have a look at INSERT (Transact-SQL)[^]
这篇关于为什么我们在传递table作为参数时使用select命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文