Re: Passing arrays to a stored procedure

From: louise raisbeck (louiseraisbeck_at_discussions.microsoft.com)
Date: 11/28/04


Date: Sun, 28 Nov 2004 13:15:05 -0800

this post was a few days ago so no idea if you will all read this but just
read this post as need to do a similar thing. this is an open forum to help
sql developers around the world and Joe your attitude was quite frankly rude
and unnecessary and felt you needn't have bothered with the energy involved
in replying.

I am also writing a stored procedure and have to put an array of values into
a stored procedure (from an asp.net drop down list). I may be wrong but I
think that Preeta may have been asking how BEST to handle an array of values,
not how to declare an array in a stored procedure, which of course you cant
do. Preeta I have found that the best way to do this really is to pass a CSV
(comma delimited) list of values into a variable of nvarchar then split out
the values in the stored procedure.

Or you could do what Joe suggested and go learn how to think and write
proper sql code and dont ask a question until you do just that!!!!

regards,

"Joe Celko" wrote:

> >> Can you pass arrays to a stored procedure? if so, how? Please
> explain. <<
>
> You reallllllly need to get a book on the basics before you try to
> program in the language.
>
> SQL uses tables as its only data structure and it holds only scalar
> (atomic) values. There are no arrays in the language. Parameters are
> scalars. You will need to break the the host language array elements
> into scalars.
>
> There are several kludges for this kind of bad programming available in
> FAQ. However, the right answer is to learn to think and write proper
> SQL code instead of trying to force your old mental model of data into
> SQL.
>
> --CELKO--
> Please post DDL, so that people do not have to guess what the keys,
> constraints, Declarative Referential Integrity, datatypes, etc. in your
> schema are. Sample data is also a good idea, along with clear
> specifications.
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
>



Relevant Pages

  • Re: Passing arrays to a stored procedure
    ... I am aware that you can't pass an array to an sp. ... > sql developers around the world and Joe your attitude was quite frankly rude ... > a stored procedure. ... >> into scalars. ...
    (microsoft.public.sqlserver.programming)
  • arrays
    ... I am aware that you can't pass an array to an sp. ... > sql developers around the world and Joe your attitude was quite frankly rude ... > a stored procedure. ... >> into scalars. ...
    (microsoft.public.sqlserver.programming)
  • Re: Store byte array into SQL Server
    ... You can use the sql command as a stored procedure type, ... > I have a byte array called signature. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Views vs Stored Procedures, whats the difference?
    ... I hope you are not suggesting you embed SQL queries into the application? ... A stored procedure logic will be exactly as fast as the algorithm you ... I understant that SQL Server supports hints. ... implementations (nestedloop, merge, hash, ..) on decent sized tables, then ...
    (comp.databases.ms-sqlserver)
  • Re: Stored Procedures - Patterns and Practices
    ... >published the reasoning behind its opinions. ... I disagree that the debate in SQL Server related discussion forums ... If the natural key is long or spans too many ... I want to call a stored procedure that adds a customer ...
    (microsoft.public.sqlserver.programming)