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

  • Home
  • SEARCH
  • 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 995519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:44:11+00:00 2026-05-16T06:44:11+00:00

I have a stored procedure in SQL Server that returns some data via a

  • 0

I have a stored procedure in SQL Server that returns some data via a select:

CREATE PROCEDURE spDDIs_Get(@ID INT) AS

IF NOT EXISTS (SELECT ID FROM tDDIs WHERE ID = @ID)
    RAISERROR('ICT0005:DDI does not exist', 18, 1)

ELSE
    SELECT D.ID, D.SchemeID, C.ID ConfigurationID, C.Description Configuration,
           D.RecordCall, D.DDINumber
      FROM tDDIs D
      LEFT JOIN tConfigurations C ON C.ID = D.ConfigurationID
     WHERE D.ID = @ID

The ConfigurationID column returned by this procedure in some cases returns a NULL.

However, in Visual Studio, when I drag this stored procedure from the Server Explorer into my DBML file that auto generates the code for use with LINQ, it incorrectly sets this column to a non-nullable variable type:

    public partial class spDDIs_GetResult
{

    private int _ID;        
    private int _SchemeID;      
    private int _ConfigurationID;       
    private string _Configuration;      
    private bool _RecordCall;       
    private string _DDINumber;

    public spDDIs_GetResult()
    {
    }

    [Column(Storage="_ID", DbType="Int NOT NULL")]
    public int ID
    {
        get
        {
            return this._ID;
        }
        set
        {
            if ((this._ID != value))
            {
                this._ID = value;
            }
        }
    }

    [Column(Storage="_SchemeID", DbType="Int NOT NULL")]
    public int SchemeID
    {
        get
        {
            return this._SchemeID;
        }
        set
        {
            if ((this._SchemeID != value))
            {
                this._SchemeID = value;
            }
        }
    }

    [Column(Storage="_ConfigurationID", DbType="Int NOT NULL")]
    public int ConfigurationID
    {
        get
        {
            return this._ConfigurationID;
        }
        set
        {
            if ((this._ConfigurationID != value))
            {
                this._ConfigurationID = value;
            }
        }
    }

            // .... rest of the class omitted ....

}

I need the definition to be:

private int? _ConfigurationID;

not:

private int _ConfigurationID;

The definition of the method also has an attribute marking it as Int NOT NULL. I don’t mind fixing this manually in the generated code, but if I need to make changes to the stored procedure and re-import it, the variables go back to non-nullable, which causes an error, and it’s a real pain to keep this updated.

How can I either get it to import correctly and allow nulls, or make sure my edited code doesn’t get overwritten? Is there some way to add attributes to the stored procedure in SQL Server to mark the column as nullable?

Thanks,
Ben

  • 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-16T06:44:12+00:00Added an answer on May 16, 2026 at 6:44 am

    I’m worked this problem out myself. I was taking the column from the wrong table in the query. If I change the query to this, it works:

            SELECT D.ID, D.SchemeID, D.ConfigurationID, C.Description Configuration,
               D.RecordCall, D.DDINumber
          FROM tDDIs D
          LEFT JOIN tConfigurations C ON C.ID = D.ConfigurationID
         WHERE D.ID = @ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server stored procedure that is not returning any data when
Let's say I have a stored procedure in Microsoft SQL Server 2005 that returns
I have a stored procedure on my server that inserts some parameters and returns
I have an app that runs a stored procedure in SQL Server, checking the
On our SQL Server (Version 10.0.1600), I have a stored procedure that I wrote.
I have written a SQL Server stored procedure that includes a DateTime parameter. This
I have a SQL Server 2008 stored procedure that updates values in a table.
I'm developing a C# SQL Server 2005 stored procedure that does data validation for
I made a query to SQL Server to get some data via a Stored
I have a stored procedure that runs custom backups for around 60 SQL servers

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.