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.
C#SQL

Avatar of undefined
Last Comment
AlHal2
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of D B
D B
Flag of United States of America image

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?
Avatar of D B
D B
Flag of United States of America image

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
AlHal2
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo