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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
Two possible things you could try:

You could modify the SP to expect two columns.  (The 'new' column is just ignored).

You also create a new DataTable in memory with the one column and copy the column contents from the two column table into this one column table and pass that into the SP - the SP is not modified in this case.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Doug BishopDatabase DeveloperCommented:
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?
Doug BishopDatabase DeveloperCommented:
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?
AlHal2Author Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.