Link to home
Start Free TrialLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Pass single column of datatable to stored proc

I have a stored procedure which is expecting a data table with one column (user defined table type in SQL Server).
The data table has had to include an extra column, so the stored proc is failing due to the extra column.
How can I pass the first column of the data table to the stored proc.
I'm using C# in Visual Studio 2017.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is no reason the stored proc should fail because the table has multiple columns or even because a column was added to the UDTT.. We pass user defined table types with 8-10 columns into stored procedures all the time with no problems. What is the syntax you are using in your ADO Command object to make the call to the procedure?
Typically, a UDTT is populated in one stored procedure and then passed to a second procedure as a parameter. Are you attempting to populate the UDTT in your C# code and then passing it to a procedure to consume or are you using the first method?
Avatar of AlHal2

ASKER

I'm populating the UDTT in my C# code by calling one stored procedure.  I'm then passing the UDTT to a second stored procedure.
I need to amend the fist stored procedure to include a column required for filtering.  I can't amend the second stored procedure as it's used elsewhere.  Andy's suggestion has worked.