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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 autogenarated key

Author  Topic 

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-05-25 : 02:18:51
I have one table which contains emp.id as autogenrated key.

After inserting add, i want to display the emp.id of the added employee.

The emp.id should also be prefixed with company name also

for example.: ABB007

how to do in sqlserver query?

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-05-25 : 02:25:14
You can use one of the below methods to get the last identity value.

@@IDENTITY
IDENT_CURRENT
SCOPE_IDENTITY()

And you can do the concatenation in front end for company name.

Go to Top of Page
   

- Advertisement -