Cursors
SQL statements are good for set at a time operations. So it is good for for handling a group of data. But there are scenarios when you want to update a row depending upon a some specific criteria, like loop through the rows and update the row. This time we are using cursors
There are different steps to create cursors
1.Declare
2.Open
3.Fetch
4.Operation
4.Close and deallocate.
Difference between delete and truncate statements?
Delete is data manipulation language
Truncate is data definition language
Truncate Cannot be rollnacked while delete can be
Can not use trancate on a table referenced be foreign key
Delete table sysntax logs the delete, truncate table does not log any information but it logs information about deallocation of data page of table.
Delete can have criteria while truncate can not
Trucate reset the identity of the table, while delete do not reset the identity.
SQL statements are good for set at a time operations. So it is good for for handling a group of data. But there are scenarios when you want to update a row depending upon a some specific criteria, like loop through the rows and update the row. This time we are using cursors
There are different steps to create cursors
1.Declare
2.Open
3.Fetch
4.Operation
4.Close and deallocate.
Difference between delete and truncate statements?
Delete is data manipulation language
Truncate is data definition language
Truncate Cannot be rollnacked while delete can be
Can not use trancate on a table referenced be foreign key
Delete table sysntax logs the delete, truncate table does not log any information but it logs information about deallocation of data page of table.
Delete can have criteria while truncate can not
Trucate reset the identity of the table, while delete do not reset the identity.
Comments
Post a Comment