Answer: This IDENT_CURRENT function is used to return a value which is the last identity value inserted in the table.
It takes only one parameter i.e., table name.
Example:
Now here is an example of creating a table with identity column and inserting values in it.
Create table emp_dummy
{
ID int IDENTITY(5,2),
Name varchar(20)
}
In the above created table, IDENTITY(5,2) means the identity values will start from 5 and will increment by 2.
Insert emp_dummy values('ABC')
Insert emp_dummy values('XYZ')
Select * from emp_dummy
Output:
ID Name
5 ABC
7 XYZ
Select IDENT_CURRENT('emp_dummy')
Result:
It displays 7 as the result
Asked In: Many Interviews |
Alert Moderator