Pages

SQL-1



1-Creating Table and Identity Column



Click on image to zoom on it
If a column is marked as an identity column, then the values for this column are automatically generated, when you insert a new row into the table







2-How to get the last generated identity column value in SQL Server?
Click on image to zoom on it
SCOPE_IDENTITY() - returns the last identity value that is created in the same session and in the same scope.
@@IDENTITY - returns the last identity value that is created in the same session and across any scope.
IDENT_CURRENT('Table Name') - returns the last identity value that is created for a specific table across any session and any scope







3-Select specific or all column and Distinct row

Click on image to zoom on it













4-Aggregate Function

Click on image to zoom on it
Click on image to zoom on it