?
Solved

Sequence Help

Posted on 2007-03-22
2
Medium Priority
?
199 Views
Last Modified: 2010-03-19
hello, i have a sequence number that I for the most part genorate myself, or the user can genorate for example 'a-3-b-ddm-axx' and if that number is in the databae, i want the database to see if that exsists, and if it does, to suggest another by using '-a' at the end of it if it is avalible.
0
Comment
Question by:wd006451
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
ksaul earned 2000 total points
ID: 18774608
declare @seq varchar(25)
set @seq = 'a-3-b-ddm-axx'

IF EXISTS (
  SELECT 1
  FROM YourTable
  WHERE SequenceField = @seq )
    IF EXISTS(
        SELECT 1
        FROM YourTable
        WHERE SequenceField LIKE @seq + '%' )
            SELECT @seq + '-'  + char(ascii(right(SequenceField,1))+ 1)
          FROM YourTable
      ELSE
            SELECT @seq + '-a'
ELSE
  SELECT @seq
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18774609
now what happens if it reaches 99,  -a99
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

765 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