Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jscot
Posting Yak Master
106 Posts |
Posted - 2010-10-19 : 23:28:02
|
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 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
jscot
Posting Yak Master
106 Posts |
Posted - 2010-10-19 : 23:51:57
|
Table is already created and i can't change table structure. and requirement is use "ORderID" as a unique and auto generate. |
|
|
jscot
Posting Yak Master
106 Posts |
Posted - 2010-10-19 : 23:52:35
|
Performance no concern, no issue! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-10-20 : 01:53:32
|
I hope you don't ever have more than one row inserted in a second, or that will no longer be unique.--Gail ShawSQL Server MVP |
|
|
jscot
Posting Yak Master
106 Posts |
Posted - 2010-10-20 : 08:56:25
|
COV Stand company name, It could be anything ABC-101020(SS) IF SECOND giving any problem then ABC-1010201,ABC-1010202,ABC-1010203 AND SO ON. Please any 1 paste a code for me, Thanks. |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-20 : 09:59:48
|
There are several things wrong with your plan.First, the two digit year limits the system to a lifetime of 10 years.Second, the two digit second limits your system to a maximum of 99 orders per day.CODO ERGO SUM |
|
|
|
|
|