Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
Incremental pattern matching
Incremental pattern matching
Rate Topic
Display Mode
Topic Options
Author
Message
liteswitch
liteswitch
Posted Friday, July 30, 2010 6:32 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, March 08, 2013 3:36 AM
Points: 24,
Visits: 145
Hi all,
I've got a column, called user_code char(3) that is used to store unique codes. The patterns are as follows
Character 1 is A-Z
Character 2 is 0-9,A-Z
Character 3 is 1-9,0,A-Z
So, the data starts at
A01
A02
...
AZZ
B01
B02
..
BZZ
..
ZZZ
Now, what I need to do is write a T-SQL statement that will tell me what the next available (ie unused) user_code can be. I wish I could just do a MAX(user_code) to find the most recently used one and then work out the next value in the sequence, but it's not that simple, as the user_codes assigned aren't in any meaningful order..
If you could help me with this, that'd be awesome. There are no constraints here really, if it means creating another lookup table with all the options in, then that's allowed, as long as the solution works!
Post #961287
GilaMonster
GilaMonster
Posted Friday, July 30, 2010 6:49 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 11:45 AM
Points: 37,744,
Visits: 30,023
Please don't cross post. It just wastes peoples time and fragments replies.
No replies to this thread please. Direct replies to:
http://www.sqlservercentral.com/Forums/Topic961290-338-1.aspx
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 #961309
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.