locked
how to make counter in database RRS feed

  • Question

  • can i make a Coulomb in database  as a counter?
    if yes please tell me how?
    if no write a way from you and write a way in query of database
    thank you
    • Edited by d-kh Monday, September 15, 2014 8:07 PM
    Monday, September 15, 2014 8:06 PM

Answers

  • Can you explain further please?

    When you say "counter", do you want this column to automatically increment when new data is inserted? If so, create an identity column in your table. To do this open the table in design mode, add a new column, as Manish suggests, avoid using keywords as a name, use type int or bigger. Then scroll down the Column properties table and locate the "Identity Specification" section click on it to expand the tree and set Is Identity to Yes.

    If you are trying to do something different please provide more detail. Saga.

     


    Insanity is the prelude to discovery

    • Marked as answer by d-kh Monday, September 15, 2014 8:21 PM
    Monday, September 15, 2014 8:18 PM
  • Sorry about the late response. I had to do some non computer related activities.

    When in table design, you enter the column name, select int as type then just below the column table you'll see the properties pane. Scroll down and it should be there. I've included a screen shot, assuming that the DB management software is the same type and version as the one I use (which is the standard Management Studio that comes with SQL Server). Hope that helps! Saga


    Insanity is the prelude to discovery

    Thursday, September 18, 2014 3:41 PM

All replies

  • Yes you can make "counter" column in sql server,  better you can just simply wrap the square brackets around the column. and also its recommended to avoid reserve words as database objects.

    Create table fun(id int, counter int)
    
    insert into fun values(1,1)
    
    select ID,counter from fun


    Thanks
    Manish
    ___________________________________________________________________________________
    Please click Mark as Answer if my post solved your problem and click Vote as Helpful if this post was useful.

    Monday, September 15, 2014 8:10 PM
  • Can you explain further please?

    When you say "counter", do you want this column to automatically increment when new data is inserted? If so, create an identity column in your table. To do this open the table in design mode, add a new column, as Manish suggests, avoid using keywords as a name, use type int or bigger. Then scroll down the Column properties table and locate the "Identity Specification" section click on it to expand the tree and set Is Identity to Yes.

    If you are trying to do something different please provide more detail. Saga.

     


    Insanity is the prelude to discovery

    • Marked as answer by d-kh Monday, September 15, 2014 8:21 PM
    Monday, September 15, 2014 8:18 PM
  •  i make a data base for a courses center and i make 3 table 

    student (student-id ,student-name ,age,semester)

    courses(course-id,name,hours)

    tutor(tutor-name,phone) tutor give a differant kind of courses i want to know the times that he give in each course what should i add

     

    Monday, September 15, 2014 8:18 PM
  • Since this is a different question from the one which you originally made and have marked as answered (thanks btw) I would recommend that you start a different thread. Many people that can help you may not open up a thread (question) that has already been answered. By starting a new thread (asking a new question) you can give it a meaningful title and have better luck at some one helping you with it. Regards, Saga

     

    Insanity is the prelude to discovery

    Monday, September 15, 2014 8:31 PM
  • thank you
    Monday, September 15, 2014 8:33 PM
  • sorry but i cant find "Identity Specification" in properties of coulmn
    Monday, September 15, 2014 8:56 PM
  • Sorry about the late response. I had to do some non computer related activities.

    When in table design, you enter the column name, select int as type then just below the column table you'll see the properties pane. Scroll down and it should be there. I've included a screen shot, assuming that the DB management software is the same type and version as the one I use (which is the standard Management Studio that comes with SQL Server). Hope that helps! Saga


    Insanity is the prelude to discovery

    Thursday, September 18, 2014 3:41 PM