Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can Stored Procedure take a Table as a Parameter
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01547558
Message ID:
01547563
Views:
55
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform