Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can Stored Procedure take a Table as a Parameter
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01547558
Message ID:
01547563
Vues:
56
>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

Do you want to pass a name of the parenttable or the table itself?

If you're using SQL Server 2008 and up, you can pass table-valued parameter.

If you want to just pass the name of the table, then you would need to use dynamic SQL.

Assuming the former, check
http://blog.sqlauthority.com/2011/08/25/sql-server-tips-from-the-sql-joes-2-pros-development-series-table-valued-store-procedure-parameters-day-25-of-35/

for usage explanation from the SQL Server side.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform