Solved

Passing a list of variables to a stored procedure

Posted on 2002-04-15
6
244 Views
Last Modified: 2013-12-24
Hi all,

I am looking for the most efficient way to pass a list, serie or array of variables to a SQL Server stored procedure and process it at once.  THks fr your help.  

Sincerely,

Racimo
0
Comment
Question by:Racim BOUDJAKDJI
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
anrazame earned 50 total points
ID: 6941531
You can call a storproc with a param as varchar
MyStorProcParam="1,3,45"
and parse it in the body of your SP.

You need to make an CF output to this param:
MyStorProcParam="#myListAsString#"
0
 
LVL 1

Expert Comment

by:anrazame
ID: 6941539
Alternatively can you save your array in the temporary table and call the SP, that uses this table. You have nothing to parse then.
0
 
LVL 23

Author Comment

by:Racim BOUDJAKDJI
ID: 6941544
anrazame,

Thks for the feedback.  I don't really need an output on this CFSTOREDPROC.  I know I would have to pass it as a varchar but that does not tell what would be the best way for SQL Server to process;  I need some kind of stored procedure example that does the job.

Sincerely,

Racimo
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 23

Author Comment

by:Racim BOUDJAKDJI
ID: 6941555
I'd rather not do any unuseful write operation.  I thought about creating a temp table but I prefer to make a single process that processes the varchar. Is there some kind of SQL Server user-defined function that does the job?

Sincerely,

Racimo
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6942220
I agree w/ anrazame, the simplest way is to pass the data comma delimited and make the stored proc handle it.

CJ
0
 
LVL 23

Author Comment

by:Racim BOUDJAKDJI
ID: 6944383
Hi guys,

I KNOW that passing it as a string would be the solution.  I was just expecting an optimized and complete solution.  BTW, I found a solution which is to create a T-SQL function to emulate the split VB function then use the CFSTOREDPROC to pass the varchar delimmited string.  I guess I should have asked this question on the SQL board...

As it's my mistake, I will grant the points to anrazame.

Here is the link to the solution I have found for anybody interested

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlmag01/html/TreatYourself.asp
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Website Test Question 6 116
VPN Dedicated IP address question 7 45
PHP in Apache server 20 95
Has my website been infiltrated? 21 66
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question