邹建《中文版SQL Server 2000开发与管理应用实例》新书第427页。。。
第427页上面有个表格:
表14-4 sp_MSforeachtable、sp_MSforeachdb和sp_MSforeach_worker的参数定义及参数说明
参数定义 描述
@command1 nvarchar(2000) 第1条运行的Transact-SQL语句。sp_MSforeach_worker无此参数
但实际上,我们看系统存储过程sp_MSforeach_worker 的定义是有@command1这个输入参数的。
/*
* This is the worker proc for all of the "for each" type procs. Its function is to read the
* next replacement name from the cursor (which returns only a single name), plug it into the
* replacement locations for the commands, and execute them. It assumes the cursor "hCForEach"
* has already been opened by its caller.
*/
create proc sp_MSforeach_worker
@command1 nvarchar(2000), @replacechar nchar(1) = N'?', @command2 nvarchar(2000) = null, @command3 nvarchar(2000) = null
as
create table #qtemp ( /* Temp command storage */
qnum int NOT NULL,
qchar nvarchar(2000) COLLATE database_default NULL
)