13. Differences Between @@IDENTITY, SCOPE_IDENTITY() and IDENT_CURRENT in SQL by Pandey Guruji

Download Complete SQL Training Materials: imojo.in/sqlpandeyguruji
------------------------------------------------------------------------------------------------------------------------------------------
This Video contains In-depth coverage of @@IDENTITY Vs SCOPE_IDENTITY() Vs IDENT_CURRENT in SQL. Covers all of the important queries and SQL commands. You'll learn how to read and write complex queries. Handle tricky SQL interview questions. Implement complex SQL queries and answer popular interview questions on SQL. This Video series will help to get jobs in SQL Developer, Database Developer, Data Engineer, Reporting Analyst, Data Analyst, Data Scientist, System Analyst, Power BI Developer, Tableau Developer, BI Developer, etc.
-----------------------------------------------------------------------------------------------------------------
Are you someone who is looking for Real-time training, visit pandeyguruji.graphy.com/ and join for free training materials, Link: bit.ly/30vrk1W
For any query Contact me on social media:
Facebook : / mpandeyguruji
Instagram: / pandey_guruji
Linkedin: / mukesh-pandey-1a151634
-------------------------------------------------------------------------------------------------------------------
SQL Tutorial for Beginners in Hindi: bit.ly/3CwfnGB
SQL Tutorial for Beginners in English: bit.ly/3qVI3GQ
SQL Live Training: bit.ly/3kXqOl1
Crack SQL Interview: bit.ly/3caxIyb
SQL Interview Questions: bit.ly/2CR6wCZ
Advance SQL Interview Questions: bit.ly/3HnMrnN
Career Guidance: bit.ly/3FffkRf
IT Technology News & Updates: bit.ly/3FeNQvc
--------------------------------------------------------------------------------------------------------------------
SCOPE_IDENTITY is:
SCOPE_IDENTITY returns the last IDENTITY value inserted into an IDENTITY column in the same scope.
SCOPE_IDENTITY returns the last identity value generated for any table in the current session and the current scope.
A scope is a module; a Stored Procedure, trigger, function, or batch.
Thus, two statements are in the same scope if they are in the same Stored Procedure, function, or batch.
The SCOPE_IDENTITY() function will return the NULL value if the function is invoked before any insert statements into an identity column occur in the scope.
What IDENT_CURRENT is
IDENT_CURRENT is:
IDENT_CURRENT returns the last identity value generated for a specific table in any session and any scope.
IDENT_CURRENT is not limited by scope and session; it is limited to a specified table.
@@IDENTITY is:
@@IDENTITY returns the last identity value generated for any table in the current session, across all scopes.
After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY contains the last identity value generated by the statement.
If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL.
If multiple rows are inserted, generating multiple identity values, @@IDENTITY returns the last identity value generated.
The @@IDENTITY value does not revert to a previous setting if the INSERT or SELECT INTO statement or bulk copy fails, or if the transaction is rolled back.
Differences
The differences between them are:
SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY are similar functions in that they return values inserted into IDENTITY columns.
SCOPE_IDENTITY and @@IDENTITY will return the last identity values generated in any table in the current session.
However, SCOPE_IDENTITY returns values inserted only within the current scope;
@@IDENTITY is not limited to a specific scope. A scope is a module; a Stored Procedure, trigger, function, or batch.
#Call_Now_8309569513_Realtime_One_to_One_Training

Пікірлер: 6

  • @rifaqatullah2379
    @rifaqatullah23796 ай бұрын

    Thanks Guruji

  • @PinnkGoat
    @PinnkGoat5 ай бұрын

  • @PandeyGuruji
    @PandeyGuruji17 күн бұрын

    Subscribe My Vlog Channel: www.youtube.com/@pandeygurujivlog Subscribe Technical Channel: kzread.info Facebook: facebook.com/pandeygurujivlog

  • @dharmandharman9070
    @dharmandharman9070 Жыл бұрын

    Nyz

  • @vijayfulwar6172
    @vijayfulwar6172 Жыл бұрын

    Great explained. Sad to see so less likes

  • @PandeyGuruji

    @PandeyGuruji

    Жыл бұрын

    Thank you.