Workflow Soluiton

 View Only
  • 1.  SQL table-column property

    Posted Dec 31, 2010 01:58 AM
    This is more of an SQL question but here are the details I am using a Workflowswat guide to create a change management system I have a Change_Id column and I need it to increment. I do not want 1,2,3 and so on. I would like to do something like HCM-0001, HCM-0002 and so on Any input would be of huge appreciation


  • 2.  RE: SQL table-column property
    Best Answer

    Posted Jan 01, 2011 11:47 AM

    You'll probably need an integer column that's an identity to make this work easily. Lets say the column 'ID' is an integer that starts at 1, and increments by 1.

    Then you could do something like this.

    DECLARE MAXID INT

    DECLARE CHANGEID VARCHAR(20)

    SET MAXID = SELECT MAX(ID) FROM CHANGE --Gets the highest ID value

    SET CHANGEID = 'HCM-000' + CAST(MAXID + 1 AS VARCHAR) --Builds the Change ID value

    After that, you can use your new CHANGEID in an insert statement

     

    However, if you're just intersted in changing the prefix of a task ID (i.e CM-0x -> HCM-0x), this is all controlled on the Reporting tab of the project properties (click on parent node of project, hit reporting tab). You can manipulate the prexix and padding of the task ID here.



  • 3.  RE: SQL table-column property

    Posted Jan 03, 2011 03:53 PM

    Thanks very much Reecardo, it is always appreciated.  I may put this into a revision 2 of my Workflow but for now I think I will just go with 1, 2, 3.  I will mark this as a solution though as I am sure this process will work.



  • 4.  RE: SQL table-column property

    Posted Jan 13, 2011 11:02 AM

    I would think that the HCM-00000 scheme would be handled in your application. You're inserting logic into your database with that idea. Why not add a process ID column and link it to a table that stores prefixes for your processes or something like that. I think you would be locking yourself into place by using HCM- directly in the table (although altiris did it with ServiceDesk).

     

    Also there's a way to use process manager to create a custom scheme like what you're after. You can give it a prefix and make it generate a padded integer automatically. You might have to ask someone how to do this -- I've done it in a process but it has been too long ago.