SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Coding Herarchy
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

asif372
Posting Yak Master

Pakistan
100 Posts

Posted - 12/08/2012 :  14:12:13  Show Profile
I want to work on this Criteria

Item code is defined in three columns in the database...
1. ItemCode which will store current item code after concatenating it with headcode.
2. HeadCode which is the predecessor of the current item.
3. ItemLevel which will store the hierarchy order of the item.

Lets suppose we have selected a Control for that item whose item code was stored in the database as 101,this means it's itemlevel is 2(1st digit for level 1 and 2nd and 3rd for level 2).
------------------------------------
ItemCode HeadCode ItemLevel
101 1 2
-------------------------------------

Now when we select current item, we will take its predecessor control item's itemcode as its head code ...increment the predecessor control item's itemlevel and concatenate the new item code with the headcode(101+01)...i have taken 01 because it is the 1st item of level 3...if level 3 items already exist just assign the code likewise...for example if u see that there are already 3 items of level 3...you will assign the new itemcode as:10104...

--------------------------------------
ItemCode HeadCode ItemLevel
10101 101 3
--------------------------------------

Edited by - asif372 on 12/09/2012 08:45:15

robvolk
Most Valuable Yak

USA
15678 Posts

Posted - 12/10/2012 :  17:13:46  Show Profile  Visit robvolk's Homepage
Dupe of: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=181348

And placed in wrong forum. Locking this, please direct posts to above link.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000