Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to add automatically value

Author  Topic 

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-15 : 03:20:32

In my table have two field

Ex
TableName===> Details
-----------
No ===========>int primary key

Name =========>Char(50)
---------

i need automatically add value in first field(No)..

Once execute insert command using only second field

after automatically generated first field value

Result
--------
No Name
1 dfgd
2 dgdg
.......
--------

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-15 : 03:23:56
Make No as identity column.

CREATE TABLE dbo.Details
(
[No] int Identity(1,1),
[Name] Varchar(50)
)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-15 : 03:43:42

Thanks very much

Go to Top of Page
   

- Advertisement -