Discussion on:

5
Comments

Join the conversation!

Follow via:
RSS
Email Alert
0 Votes
+ -
Nice Article
kobypitz 1st Sep 2009
Can you show an example for passin table based value from c# code, i meen, what the type of System.Data.SqlTypes i need to set for the parameter in this case...

thanks in advance
Koby
Normally I'd say you owed me thumb, but I just learnt somthing by trying to answer your question.

Here you go

http://lennilobel.wordpress.com/2009/07/29/sql-server-2008-table-valued-parameters-and-c-custom-iterators-a-match-made-in-heaven/

How do you programatically call this SP from say C# and pass this table as input or how do you construct this table in the code to pass it as a parameter. It would be interesting to see the parameter binding as well. thanks.
0 Votes
+ -
I know that this thread is already pretty old, but here is an example that I found of calling a stored procedure with a table type as a variable:

http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters

Hopefully, this will help someone in the future.

Thanks,

Chris
0 Votes
+ -
My solution
joshgeake 15th Apr 2011
I did this a while ago and it's running in several production stored procedures.

Essentially you need to form a dynamic SQL statement by stitching together strings and then execute it. See here for the full post - http://www.geakeit.co.uk/2011/02/05/a-table-input-variable-in-a-stored-procedure-and-bypassing-must-declare-the-table-variable-msg-1087/
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.