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 6737545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:15:41+00:00 2026-05-26T11:15:41+00:00

I have a view that has an INSTEAD OF INSERT trigger (in SQL Server

  • 0

I have a view that has an INSTEAD OF INSERT trigger (in SQL Server 2005). When the user inserts into the view, they are in fact making inserts and updates to a number of tables. The view is sufficiently complex that it cannot have an index, so is unfortunately unconstrained.

The view is being inserted into from C# using code that would be problematic to change. This code catches primary and unique key violations using the following:

try
{
    ... // Insert into view
}
catch (SqlException ex)
{
    if (ex.Number == 2627 || ex.Number == 2601) // Primary key exception, unique constraint violation
    {
        ... // Report the duplicate entry to the user
    }
    else
    {
        throw;
    }
}

So my question is: can I use RAISERROR within my trigger to create an exception with number 2627 or 2601?

  • 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-26T11:15:42+00:00Added an answer on May 26, 2026 at 11:15 am

    No. You’ll have to wait for THROW in the next release (maybe)

    You can only throw errors that you have put into sys.messages (50000+), or with text that gives 50000. Or embed it in the text and change your c#. You can’t throw errors less than 50000

    If the view is so complex that you can’t use DRI, then it is too complex. Also, you’ll have concurrency issues: overlapping calls will break your "uniqueness" at some point when you roll your own.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that has a UINavigationController that pushes a UITabBarController into view.
I have created an INSTEAD OF INSERT trigger on a view in my database.
I have a legacy SQL Server 2000 database that has one column that has
I have a view that has a list of jobs in it, with data
I'm using MVC2 with VS2010 I have a view that has two partial views
I have a picker view that has a list of numbers to pick from.
I have a view controller class that has to implement several protocols. Too keep
I have an iPhone app that shows a simple view (View 1) that has
I have a navigation view with a cell that has something as simple as
I have an app that has a centre view with two views off to

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.