Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3722472
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:55:02+00:00 2026-05-19T05:55:02+00:00

I have this SQL Server 2008 UDT: CREATE TYPE [dbo].[IdentityType] AS TABLE( [Id] [int]

  • 0

I have this SQL Server 2008 UDT:

CREATE TYPE [dbo].[IdentityType] AS TABLE(
    [Id] [int] NOT NULL
)

Pretty simple. Basically allows me to hold onto a list of id’s.

I have this stored procedure:

CREATE PROCEDURE [dbo].[Scoring_ScoreMultipleLocations]
    @LocationIds [IdentityType] READONLY,
    @DoRanking BIT = 0
AS
BEGIN
   -- irrelevant code.
END

Entity Framework 4.0 does not support executing stored procedures that take user defined table types as a parameter, so i’m reverting to classic ADO.NET. The only other option is passing a comma-seperated string.

Anyway, i found this article, but it’s a little hard to follow.

I don’t understand what this line of code is doing:

DataTable dt = preparedatatable();

They don’t even provide that method, so i have no idea what i’m supposed to do here.

This is my method signature:

internal static void ScoreLocations(List<int> locationIds, bool doRanking)
{
   // how do i create DataTable??
}

So i have a list of int and need to pump that into the UDT.

Can anyone help me out/point me to a clear article on how to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:55:03+00:00Added an answer on May 19, 2026 at 5:55 am

    This article might be a bit more help.

    Essentially, you’ll create a new DataTable that matches the schema, then pass it as a parameter.

    The code of preparedatatable() probably would look something like:

    var dt = new DataTable();
    dt.Columns.Add("Id", typeof(int));
    return dt;
    

    After which, you’d have to add your locationIds:

    foreach(var id in locationIds)
    {
        var row = dt.NewRow();
        row["Id"] = id;
        dt.Rows.Add(row);
    }
    

    Then assign dt as a parameter:

    var param = cmd.Parameters.AddWithValue("@LocationIDs", dt);
    param.SqlDbType = SqlDbType.Structured;
    param.TypeName = "dbo.IdentityType";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table structure on a SQL Server 2008 R2 database: CREATE TABLE
I have a table like this in my database (SQL Server 2008) ID Type
Say, I have a table like this (SQL Server 2008): CREATE TABLE tbl (ID
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have a SQL Server 2008 DB with a table like this (Table1): ID
I have this table in a SQL Server 2008 R2 instance which I have
i have this sp: using sql server 2008 create procedure SelectTopCounts @Id bigint =
I have this table insurance in SQL Server 2008 insuranceId StartDate EndDate CarID 1
I currently have this statement in my SQL View (SQL Server 2008 R2) which
This is SQL Server 2008. I have these two tables and a join: DECLARE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.