Development

SQL Server – Rollback transaction completely in case of error

Hi friends, I recently found an issue while inserting data into table during transactions that transaction will not completely rollback if we use multiple insert statement in transaction. Let me give you a demo on this how to handle such situation. Create table Test_tran (               ID Int Primary… Continue reading SQL Server – Rollback transaction completely in case of error

Development

SQL Server – Conditions when value of @@error changes

Hi friends, when we do error handling in our SQL code we use different methods like TRY/CATCH, RAISERROR etc. to return the error messages. We also use global variable @@error to print the error value of the last T-SQL statement executed. But many folks doesn’t know that value of @@error gets reset with every execution… Continue reading SQL Server – Conditions when value of @@error changes

Development

SQL Server – Change in Identity() Property during transactions

Recently while working on a scenario I found that in case of transaction if you are doing insertion operation on a table and when you Rollback your transaction then identity value that is inserted to the table is not rolled back. Let me demo you on this scenario using an example. First we will create… Continue reading SQL Server – Change in Identity() Property during transactions

Development · Performance Tuning

SQL Server – Cleaning Procedure Cache for a particular database

HI friends, most of the time we used DBCC FREEPROCCACHE to clear the procedure cache, clears the specific plan from cache by specifying plan handle or SQL handle. DBCC FREEPROCCACHE does not require any parameters. To clear the plan cache we just need to execute below query – DBCC FREEPROCCACHE Whenever we execute this command,… Continue reading SQL Server – Cleaning Procedure Cache for a particular database

Development

SQL Server – Row Level Security in SQL Server 2016 – Part 3

Hi friends, continuing from the previous post in this post we will learn how to add the blocking predicate to restrict the users to perform DML operation (INSERT, UPDATE, DELETE) for others users data. If you want to read the previous posts on Row Level Security you can find those post here: https://kapilsqlgeek.com/2016/05/03/sql-server-row-level-security-in-sql-server-2016-part-1/ https://kapilsqlgeek.com/2016/05/05/sql-server-row-level-security-in-sql-2016-part-2/ Let’s… Continue reading SQL Server – Row Level Security in SQL Server 2016 – Part 3

Development

SQL Server – Row Level Security in SQL 2016 – Part 2

Hi friends, in my previous post we have learnt how to implement Row Level Security feature in our database. You can find the link of Part1 here: https://kapilsqlgeek.com/2016/05/03/sql-server-row-level-security-in-sql-server-2016-part-1/ In this post we will discuss more on Row Level Security and see what will happen if we give users DML operation rights other than SELECT operation… Continue reading SQL Server – Row Level Security in SQL 2016 – Part 2

Development

SQL Server – Row Level security in SQL Server 2016 – Part 1

Hi friends, in SQL 2016 several new security features gets introduced which will help users to protect their data in many ways. Today, I will discuss new security feature Row Level Security (RLS) which implements the security inside the database itself, not at application level. Suppose we have some critical business data and want to… Continue reading SQL Server – Row Level security in SQL Server 2016 – Part 1