Autogenerate "OrderID"

  • I have a field called "OrderID" i want this field auto generate"Unique" let say "COV-YYMMDDSS" so every time ORderid create it should be unique. Please send me t-sql code. Thanks in advance.

  • Your requirement is not clear.

    What do you mean by "auto generate"? Are you looking for some kind of an identity column in a custom format?

    To ensure you only have unique entries ou could add a UNIQUE constraint to your table. See BOL (BooksOnLine, the SQL Server help system usually installed together with SQL Server), section "ALTER TABLE (Transact-SQL) ".

    Please send me t-sql code.

    Sure. Please send me the money. 😉

    We're here to help you to improve your T-SQL skills, not to do your job for you.

    Give it a try first, see where you get stuck and post back what you have so far.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Also asked here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151816

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • And you may want to consider some of the points people mentioned on this other thread:

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151816

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply