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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Call SP foreach Column in Table (without Cursor)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gpc44
Starting Member

35 Posts

Posted - 08/17/2013 :  01:26:10  Show Profile  Reply with Quote
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

Edited by - gpc44 on 08/17/2013 03:58:43

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 08/17/2013 :  09:21:01  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000