Some questions are extremely popular questions and they never get old. Here is one such question which I see very often asked to DBAs in their early career. Question: How to re-index every table of the database? Answer: Well, The answer of this question can be only given in the form of the…
Read MoreSQL SERVER – The Basics of the Execute Package Task – Notes from the Field #067
[Note from Pinal]: This is a new episode of Notes from the Field series. SQL Server Integration Service (SSIS) is one of the most key essential part of the entire Business Intelligence (BI) story. It is a platform for data integration and workflow applications. In this episode of the Notes from the…
Read MoreSQL SERVER – Script to Find Leap Year
A leap year has 366 days. A leap year has 29 days for February month. Suppose you want to find if year is Leap year or not, you can use many methods. But this is one of the simplest methods. In our example I have passed the year 2000 as…
Read MoreSQL SERVER – Viewing User Configurable Info in SQL Server
Most of the blog post as I say is revisiting something I wrote a while back in this blog. Recently one my blog readers asked me about user defined counters and he seems to have bumped into the blog: How to use Procedure sp_user_counter1 to sp_user_counter10 and was thinking if…
Read MoreInterview Question of the Week #006 – Is Shrinking Database Good or Bad?
Here is the most debated Interview Question – Is Shrinking Database Good or Bad? I will try to answer this in a single statement – “Shrinking Database is bad practice for performance as it increases fragmentation. It should be used in rare cases of running out of space on drive.” I believe above…
Read MoreSQL SERVER – What are the Different Ways to Script Procedure with T-SQL
Ever wondered how a simple task can be done multiple ways. You can script a stored procedure in many ways. You can use SSMS tool and use Generate Script option. However, if you want to do it in T-SQL, there are four ways. Let us create this simple procedure CREATE…
Read MoreSQL SERVER – One Trick of Handling Dynamic SQL to Avoid SQL Injection Attack?
SQL Server has so many things to learn and I always find it amazing. My conversations with customers often come up with security questions esp around SQL Injection. Many have claimed SQL Injection is a SQL Server problem. It takes quite some time for me to let them know there is nothing about SQL Server and SQL Injection. SQL Injection is an outcome of wrong coding practices. One of the recommendations I give is about not using Dynamic SQL. There might be some situations where you can’t avoid it. My only advice would be, avoid if possible. In this blog, I would demonstrate a SQL Injection problem due to dynamic SQL and a possible solution you can have.