Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Autogenerate "OrderID" Expand / Collapse
Author
Message
Posted Tuesday, October 19, 2010 9:11 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 12:57 PM
Points: 219, Visits: 826
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.
Post #1007434
Posted Wednesday, October 20, 2010 1:55 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Sunday, September 7, 2014 11:27 PM
Points: 7,164, Visits: 13,257
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
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1007995
Posted Wednesday, October 20, 2010 2:07 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:39 PM
Points: 42,953, Visits: 36,110
Also asked here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151816


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1008007
Posted Wednesday, October 20, 2010 2:07 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 12:37 PM
Points: 3,136, Visits: 11,488
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







Post #1008008
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse