Append prefix to OrderID upon insert of new record

Posted on 2007-10-03
Last Modified: 2012-06-27
Upon the insert of a new record, I need to append a two character prefix to the OrderID which is an identity value.

How would I accomplish with in SQL Server 2005 ?
Question by:jnsimex
    LVL 25

    Accepted Solution


    As far as I know you can't do this. The identity field is managed by SQL and can't be altered. It will error if you alter it. The only way around this is to have a second field that contains the same value as the identity value which you can then alter. You would do this with a SQL trigger.


    LVL 27

    Expert Comment

    Yes, Isavidge is right.

    The ID property must be a numeric value. You cannot modify the column to accept characters and maintain the IDENTITY property. The identity options are grayed out.


    Author Comment

    thanks guys!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now