Hai All,
INSERT INTO tablename(Name) VALUES (@Name)
SET @res = (SELECT SCOPE_IDENTITY())
here the "SCOPE_IDENTITY()" will return the row id of the just inserted raw of that instance.
In Some Situation we may face to use "@@IDENTITY"
INSERT INTO tablename(Name) VALUES (@Name)
SET @res = (SELECT @@IDENTITY)
it differs the value while using the triggers for inserting, if we use triggers, "@@ IDENTITY" will return the trigger value identity.
Thanks
While Programming with the SQL we may face situations to get the newly inserted raw Id from the query. Here i am showing the example code to achieve the same.
INSERT INTO tablename(Name) VALUES (@Name)
SET @res = (SELECT SCOPE_IDENTITY())
here the "SCOPE_IDENTITY()" will return the row id of the just inserted raw of that instance.
In Some Situation we may face to use "@@IDENTITY"
INSERT INTO tablename(Name) VALUES (@Name)
SET @res = (SELECT @@IDENTITY)
it differs the value while using the triggers for inserting, if we use triggers, "@@ IDENTITY" will return the trigger value identity.
Thanks
0 comments:
Post a Comment