Re: Passing arrays to a stored procedure
From: louise raisbeck (louiseraisbeck_at_discussions.microsoft.com)
Date: 11/28/04
- Next message: Frank Dulk: "When to Close the Connection?"
- Previous message: John Bell: "Re: Best Pract for retrieval of Timestamp, Guid, and other in Ins/Upd?"
- In reply to: Joe Celko: "Re: Passing arrays to a stored procedure"
- Messages sorted by: [ date ] [ thread ]
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!
>
- Next message: Frank Dulk: "When to Close the Connection?"
- Previous message: John Bell: "Re: Best Pract for retrieval of Timestamp, Guid, and other in Ins/Upd?"
- In reply to: Joe Celko: "Re: Passing arrays to a stored procedure"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|