?
Solved

Passing a list of variables to a stored procedure

Posted on 2002-04-15
6
Medium Priority
?
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
anrazame earned 150 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
Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 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