Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can Stored Procedure take a Table as a Parameter
Message
De
03/07/2012 20:43:34
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01547558
Message ID:
01547620
Vues:
45
>Hi.
>I want to pass a Table of Primary keys to a stored procedure, with the intention of selecting out ALL children related to All the Rows passed into the SP.
>Something Like following in Stored Procedure:
>
>
>Select * from @ParentTable join ChildTable on ParetPK = ChildFK
>
>
>Just wondering is it possible to pass the ParentTable as a parameter to the Stored Procedure. Code examples would be appreciated
>The ParentTable is the Parameter I want to Pass in
>ChildTable is a SqlServer Table in a database
>
>Tia
>Gerard

My guess is you don't want to pass in the whole parent table but rather a list of primary keys in order to get all the children for a set of parents. If this is the case and you are calling it from .NET remember you can pass a List of T or anything that implements iEnumerable to an SP that accepts a table valued parameter.

It is useful to create a table valued data type in your sql table and a stored procedure that accepts parameter of that type which then does basically what you are showing in code above.

Do I remember correctly that you used Strataframe at one time? If so, you might find a writeup I did on the SF forum useful. I used this technique a lot with SF.

This spells it out in a lot of detail ( the techniques described are not at all limited to SF )

http://forum.strataframe.net/Topic24706.aspx

Kevin Goff had a great Baker's Dozen article in the July 2008 issue of Code Magazine that got me started on this. For some reason it is impossible to fine on the CM website but if you google around for Kevin's blog and then search you''ll find it there.


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform