Hi,

I am generating a code in sql server 2005 storedprocedure. Which will be consider first 3 letter of location then the automatic generated code. And I am following the listed logic for generate this...

Step 1: Generate the first three characters based on the location. Say Location is Detroit & Characters are DET.

Step 2: Check if these characters match any other Locations first 3 characters.

Step 3: Determine the Location which matches. Here it will match with Detroit Warehouse;If it matches then go to Step 4

Step 4: Read the next character of the Location in Step 1 and match it with the Matched Location in Step 3. If matches repeat Step 4. Else Go to Step 5

Step 5: Obtain the last character obtained in step 4 that did not match and Append this unmatched character to the Prefix obtained in Step 1 i.e. W. Which makes the prefix as DETW.

So for this what will be the best solution to get the correct result.

Please help me, it is very urgent...

Thanks in advance.