Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Call SP foreach Column in Table (without Cursor)

Author  Topic 

gpc44
Starting Member

35 Posts

Posted - 2013-08-17 : 01:26:10
Hi,
Is there a way to call a SP for each row in a table, and to specify the value as a parameter? Like this....
Regards
Nicole

----------------------------------------
Create PROCEDURE [dbo].[sp_Proceed]
AS
BEGIN
-- i want to read @Filename from Table
DECLARE @sql NVARCHAR(4000) = 'BULK INSERT TblValues FROM ''' + @FileName
+ ''' WITH ( FIELDTERMINATOR ='','', ROWTERMINATOR =''\n'' )' ;
EXEC(@sql) ;
END

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-17 : 09:21:01
you need a loop for that. Otherwise you need to change sp to accept group of values and do processing

http://www.sommarskog.se/arrays-in-sql-2008.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -