Solved

Passing a list of variables to a stored procedure

Posted on 2002-04-15
6
243 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

New My Cloud Pro Series - organize everything!

With space to keep virtually everything, the My Cloud Pro Series offers your team the network storage to edit, save and share production files from anywhere with an internet connection. Compatible with both Mac and PC, you're able to protect your content regardless of OS.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
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…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now