Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Identity Primary Key

tejal_k_mehtatejal_k_mehta Member Posts: 23
Hi,

I m devloping one web application using Asp.net-2003 and Microsoft SQL Server 2000.
Microsoft SQL Server 2000 has one feature call Identity to generate the autonumber for Primary key.

Is it good to use "Identity" feature for generating Primary key numbers or i should generate it manually using "Select max(Field) from TableName" query.

Pls help in this regard.

It's urgent

-Regards.

Comments

  • ShanooShanoo Member Posts: 32
    [b][red]This message was edited by Shanoo at 2005-4-25 2:4:50[/red][/b][hr]
    [b][red]This message was edited by Shanoo at 2005-4-25 2:2:21[/red][/b][hr]
    It is always a good idea to use funtionalities provided by the RDBMS for the sake of optimization. However, in addition to defining your primary key column as identity, please make sure to also define the primary key constraint on this column (I have seen some implementations where the designers only define PK columns as identity without defining the PK constraints on these columns)

    Using a query for generating PK values adds additional overheads:
    - Additional Network request
    - Additional Query: will be parsed and executed by SQL Server on every call
    - Will return the data to the client over the network.
    - Additional inetrmediate layer (SqlClient/ADO/DAO/RDO) objects will be created to hold the data on the client side.




Sign In or Register to comment.