How to create auto increment value in my column using identity ?

hi Team,
I have an requirement where i create an auto increment value ,with my table column
Create table Temp(
DeptID int IDENTITY(1,1) PRIMARY KEY,
Name varchar(50),
Emailid nvarchar(50),
Phone varchar(50)
so this is my table structure ,Here my column name is
Deptid here i need to creat an autoincrement value with today's date like below
ex:STM0000120012015
    STM0000221012015
    STM0000322012015(Currentdate)
.......................................... like this
Here i need  only one column like identity column with the given incremental order,not more than one column
so can u pls help me out any one.
Thanks!

Here the output came like this ,
1 STM0000120150121
2 STM0000220150121
3 STM0000320150121
4 STM0000420150121
5 STM0000520150121
6 STM0000620150121
7 STM0000720150121
8 STM0000820150121
9 STM0000920150121
10 STM00001020150121 --see this exceed length
and here i dnt need to increment that Stm000010,Here my output will come like this, idnt need to increment my charcter size
1 STM0000120150121
2 STM0000220150121
3 STM0000320150121
4 STM0000420150121
5 STM0000520150121
6 STM0000620150121
7 STM0000720150121
8 STM0000820150121
9 STM0000920150121
10 STM0001020150121
11    STM0001120150121
12    STM0001220150121 
so here i dont  need to increment my charcter length(16)
The length should be STM(3char)+00001(5Charcters)+CurrentDateFormat,
see the above suggested o/p
so can u pls help me out Dimant

Similar Messages

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to get auto-increment value after insert on ACCESS db?

    When you insert a new record to a table with an auto-incrementing key, how do you find the value for the row you just inserted? This works differently with different databases. I know how it's done on ORACLE and mySql.
    How does it work with ACCESS through ODBC? How about MSSQL?

    I have discovered there's a LAST aggregate function which when I've tested it gets the just inserted auto-increment, but I'm not sure if it's reliable. You have to do:
    SELECT LAST(index-field) FROM table
    That ought to be faster than MAX, which I've noticed some people use. Persumable LAST will get the value from the last row in the table's natural order.
    In fact an auto-increment field has no business filling in missing slots since the main point is a a foreign key in other tables and a foreign key pointing to a deleted table row ought to be invalidated, not point to some unrelated successor record.
    I could use a separate table as a source of counters, of course, though that's one more call. In either case I'm worried about thread safety. In Oracle there are special sequence objects for this purpose which are incremented and read atomically. I'm not sure if the access driver transaction handling works adequately.
    Perhaps the safest approach might be to use a separate sequencer table and Java sychronisation to serialise access to each row in the sequencer table (assuming all the access is from the same app).

  • How to have a common value for a column using sql loader

    Hi Have a sql loader file which looks like below. But I am not getting how insert the same value for the column in all rows.
    id,
    crt_user_id
    BEGINDATA
    1;"system"
    2;"system"
    3;"system"
    So, instead of entering the crt_user_id as system in all rows, can we place the value at the top after the column name?

    Thanks Srini. your hint/suggestion helped me in finding the solution.
    LOAD DATA
    INFILE *
    BADFILE './TEST.BAD'
    DISCARDFILE './TEST.DSC'
    APPEND INTO TABLE TEST_TABLE
    Fields terminated by ";" Optionally enclosed by '"'
    ID,
    crt_user_id CONSTANT 'SOME CONSTANT VALUE'
    BEGINDATA
    1
    2
    3
    so by using CONSTANT key word, we can avoid tying the same value in the data

  • How to create a default value of timestamp column?

    I am trying to create a table with a default value on a timestamp column, can it be done?
    CREATE TABLE myTbl
    FutureDateTime date default TIMESTAMP WITH TIME ZONE '2999-12-31 23:23:59.000'
    )

    user1035690 wrote:
    I am trying to create a table with a default value on a timestamp column, can it be done?
    CREATE TABLE myTbl
    FutureDateTime date default TIMESTAMP WITH TIME ZONE '2999-12-31 23:23:59.000'
    )Yes, but you don't have a timestamp column, you have a date column.
    CREATE TABLE myTbl
       FutureDateTime date default to_date('2999-12-31 23:23:59', 'yyyy-mm-dd hh24:mi:ss')
      4  );
    Table created.
    Elapsed: 00:00:00.09
    ME_XE?And just in case you weren't aware, storing "end of time" information like this will be rough on your queries (it skewes the cost based optimizers estimates for cardinalities and could wildly throw off the estimates for your queries, resulting in bad plans). You're better off to store NULL values, NULL denoting not known values.
    Just an FYI :)

  • LINQ: Update a column with auto increment value

    Hi All,
    Greetings.
    I am very new to C# (though with lot of experience in VC++). Now a days, I am engaged in a C# project where I need to deal with ADO.NET DataTable and related classes. I am stuck up in a scenario as follows:
    I have a data table (of DataTable type) pre-populated with many rows (50000+), parsed from a log file. Now I need to add a column that will be holding index number for each records; eg. 1, 2, 3......
    I have tried to add the auto-incremented column dynamically, with seed = 0 and increment = 1, but it is not working.
    Is there any LINQ query that I can run to update the DataTable at once? Or foreach loop per DataRow is the only option here?
    I appreciate any quick suggestion on this.
    Thanks in advance.
    Sanjoy Jana.

    You should add the auto increment column to the DataTable before you pouplate it with the other data:
    //1. Create a datatable
    DataTable dt = new DataTable();
    //2. add the autoincrement column:
    DataColumn column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.AutoIncrement = true;
    column.AutoIncrementStep = 1;
    column.AutoIncrementSeed = 1;
    //3. Fill the dataTable using an SqlDataAdapter or whatever
    dt.Columns.Add(new DataColumn("name"));
    dt.Rows.Add("1");
    dt.Rows.Add("2");
    dt.Rows.Add("3");
    dt.Rows.Add("4");
    Then you don't have to add the "auto incremented" values yourself in some kind of a loop (using for example LINQ or foreach).
    If you want to know how to poplulate the DataTable from a database query using an adapter, please refer to the following page:
    http://www.dotnetperls.com/sqldataadapter
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

  • Creating auto-increment field in SharePoint List

    In SharePoint, we can create the auto-incremental field by many ways, I am going to discuss two ways of doing it.
    Calculated field
    Item Event Receiver
    1. Using Calculated field:
    Using this we can accomplish it without doing any programing and it is a relatively simple way of doing it. By using “Calculated” column in SharePoint List we can create auto-increment field. We can accomplish this by creating a new column and choosing the
    column type as “Calculated (calculation based on other columns)”. And in Formula field, we have to enter [ID]
    In fact this will be using the values from “ID” field from SharePoint list that starts from 1.
    For example, if we want to start our auto-increment column from 100, we can modify the “Formula” field of Create New column screen, we can have to enter [ID] + 99
    For detailed info please follow the blog I wrote here: http://faisalrafique.wordpress.com/2011/03/19/creating-auto-increment-field-in-sharepoint-list/
    2. Using Item Event Receiver:
    By using this strategy, users have advantage to edit the existing values, we can also avoid it by making field read-only on feature activation. Using item event receiver, on ItemAdded event, we have to find the highest value among previously added items
    and then save the incremented value to current newly created auto-incremental column.
    For code of event reciever please follow the blog I wrote here:
    http://faisalrafique.wordpress.com/2011/03/19/creating-auto-increment-field-in-sharepoint-list/
    Happy Coding

    Use Sharepoint Designer to create a Workflow for the list containing the field to increment. For my project I had an Invoice field that I wanted to start with 1001 and increment from there so I made the following workflow to do this.
    In the new workflow screen in Sharepoint Designer create two actions in Step 1:
    Calculate Current Item:ID plus 1000 (Output to Variable: calc)
    then Set AutoIncrementNumber to Variable: calc
    This is just a guide. If you just want the auto-increment to start with 1 then you can just use this step
    Set AutoIncrementNumber to Current Item:ID
    Also, make sure you select the correct name for your field in the Workflow action instead of AutoIncrementNumber.
    Save the Workflow, close it, and then open it again in Sharepoint Designer. Check the box for "Start workflow automatically when an item is created." Save it again and then click on the Publish button to make it active on the sharepoint site. The value should
    now increment for each new item created in the list.

  • Auto increment value

    Can i use an auto increment value in ldap entry?
    For example i can insert, for each ldap entry, an id that is different from the previous one.
    Thanks

    Can i use an auto increment value in ldap entry?
    For example i can insert, for each ldap entry, an id
    that is different from the previous one.
    ThanksI don't think that there is a "built-in" way to do this, but I have seen several methods for doing this. One way is to use a primary/unique key from another system (i.e. an employee number from an HR database), another way is to create a GUID for each object prior to creating it in the Directory. You can muck around in the schema to set a attribute globally unique, if you want to avoid doing the lookup for an existing entry when you create a new one.

  • How to create Formula based value field in COPA

    Hi,
    I want to know how to create formula based  value field in COPA
    My Requirement is i want to collect some value in formula based value field and want to use in copa allocation cycle as a tracing
    factor.
    anybody give some light on the same topic or requirement ?
    Thanks
    Nilesh R

    The key figure you are creating in KE2K is not a value field, i.e. you can't post to it and you can't use it in a report. It is a caluculated value that can be used only in assessment and top-down-distribution.
    In Ke2K, enter a name for your key figure, then click on the the white sheet button to create it. Now the formular area is open for input. Input your formular (e.g. VV001 + VV002 - VV003 .... where VVXXX are the technical names of value fields).
    Now click the "check formuar"-button. Then save.
    Before you can use the key figure in assessment, execute TC KEUG.
    Now the key figure is available as any value field in the tracing factor selection of your assessment cycle.
    I hope this made it clearer.
    Regards
    Nikolas

  • How to create Auto PR ?

    Kindly guide me & send me a manual for "How to create Auto PR ?"

    hi,
    Make MMR from MM01..Maintain MRP view...Enter necessary data like reorder point, MRP type, procurement type, etc..
    Then maintain the source list for the vendor material combination, make it MRP relevent using the MRP indicator in it. Enter other data like validity period etc and other necessary data in it..and save it..
    Then Go to MD03, make entries like Processing key as NTECH or NETPL or NEUPL as per your scenerio..
    Other entries like 2 for PR, 3, 1, 1, 1,
    and use tick for display result before you save the results...
    Then save it...
    Check MD05 and MD04 for your PR generation result....
    Regards
    Priyanka.P

  • How to create  Auto suggestion component by using of ADF tag

    Hi ,
    In my project, I am using the ADF frame work and I need to use the auto suggestion component.
    Can any body suggest me how to create Auto suggestion component by using of ADF tag.
    Waiting for your valuable suggestions...

    Try this forum:
    JDeveloper and ADF
    You might get a lot more response.
    Jan Kettenis

  • Create Auto increment sequence number for list view report

    Hi All,
              Am using BAM 11.1.1.6 version, Have updating list report & wants to create auto increment sequence number at report level. Is it possible to create column at run time in BAM reports.
    Please help.
    Thanks.

    Hi All,
              Am using BAM 11.1.1.6 version, Have updating list report & wants to create auto increment sequence number at report level. Is it possible to create column at run time in BAM reports.
    Please help.
    Thanks.

  • How can I get the value of "Warehose" column in a form

    How can I get the value of "Warehouse" column in the form below (I mean what table that contain this value):
    Production Supervisor >> Batches >> (Button) Material Details >> (Button) Line Allocations
    Well, for more clearly! My problem is I must have the Unit Cost of Items, so I've got it in the cm_cmpt_dtl (table), but if I want to, I must create a relation that require 2 filed, they're Item_ID and Whse_Code.
    There's no problem with Item_ID, but Whse_Code seem to be the Mission Impossible (hix, I hate that film!!!!)
    I wonder if It was right to post this topic here. But anyway I just post my question here, hope I could get some help.

    wow, many, many, many.... and many thanks!
    Just add a tiny modify to check out the Batch_type
    doc_id = (select batch_id from gme_batch_header where batch_no='&batch_number' and batch_type = 0)
    Because the batch_no can be duplicated as we also create Batch and Filrm Planned Order.
    Many thanks for your support!
    P/S: Sorry for my terrible English :P

  • How to create a Document Set in SharePoint 2013 using JavaScript Client Side Object Model (JSOM)?

    Hi,
    The requirement is to create ""Document Sets in Bulk" using JSOM. I am using the following posts:-
    http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/1904cddb-850c-4425-8205-998bfaad07d7/create-document-set-using-ecma-script
    But, when I am executing the code, I am getting error "Cannot read property 'DocumentSet' of undefined "..Please find
    below my code. I am using Content editor web part and attached my JS file with that :-
    <div>
    <label>Enter the DocumentSet Name <input type="text" id="txtGetDocumentSetName" name="DocumentSetname"/> </label> </br>
    <input type="button" id="btncreate" name="bcreateDocumentSet" value="Create Document Set" onclick="javascript:CreateDocumentSet()"/>
    </div>
    <script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"> </script>
    <script type="text/javascript">
       SP.SOD.executeFunc('sp.js','SP.ClientContext','SP.DocumentSet','SP.DocumentManagement.js',CreateDocumentSet);
    // This function is called on click of the “Create Document Set” button. 
    var ctx;
    var parentFolder;
    var newDocSetName;
    var docsetContentType;
    function CreateDocumentSet() {
        alert("In ClientContext");
        var ctx = SP.ClientContext.get_current(); 
        newDocSetName = $('#txtGetDocumentSetName').val(); 
        var docSetContentTypeID = "0x0120D520";
        alert("docSetContentTypeID:=" + docSetContentTypeID);
        var web = ctx.get_web(); 
        var list = web.get_lists().getByTitle('Current Documents'); 
        ctx.load(list);
        alert("List Loaded !!");
        parentFolder = list.get_rootFolder(); 
        ctx.load(parentFolder);
        docsetContentType = web.get_contentTypes().getById(docSetContentTypeID); 
        ctx.load(docsetContentType);
        alert("docsetContentType Loaded !!");
        ctx.executeQueryAsync(onRequestSuccess, onRequestFail);
    function onRequestSuccess() {       
        alert("In Success");
        SP.DocumentSet.DocumentSet.create(ctx, parentFolder, newDocSetName, docsetContentType.get_id());
        alert('Document Set creation successful');
    // This function runs if the executeQueryAsync call fails.
    function onRequestFail(sender, args) {
        alert("Document Set creation failed" + + args.get_message());
    Please help !!
    Vipul Jain

    Hello,
    I have already tried your solution, however in that case I get the error - "UncaughtSys.ArgumentNullException: Sys.ArgumentNullException:
    Value cannot be null.Parameter name: context"...
    Also, I tried removing SP.SOD.executeFunc
    from my code, but no success :(
    Kindly suggest !!!
    Vipul Jain

  • How to Create an Input Schedule Comparison with Data Using EVDRE

    Hello,
    I try implement the scenario described in "How to Create an Input Schedule Comparison with Data Using EVDRE".
    Once I am using the "Insert Function" from the panel and selecting the EVTIM function Excel crashes (see page 8 How to paper).
    Systems:
    BPC 7.0 NW SP02
    Office 2007
    BPCADminClient and BPCOfficeClient up to date
    Have anyone a solution?
    Thanks
    Oktay

    Hi Oktay -
    This function works in my BPC70NW SP02 system. Your issue might be that you are trying to access a TIME member that does not exist. Please make sure the offset value is a valid dimension member.
    I can confirm that EVTIM does allow the offset for base members (such as 2009.MAY) as well as parent nodes (such as 2009.Q1 or 2008.TOTAL)... BUT...the offset result of the EVTIM function needs to be a valid dimension member!
    Regards,
    Sheldon

Maybe you are looking for