You must have observed that the sample database adventureworks comes only with a mdf file as downloadable. Se let’s see how can we attach a data file without the log file/s? Mostly when you are on the latest version of Continue Reading..
Checking a column existence in a table is very simple in SQL Server, but you should be careful while doing it on Azure environment. We simply ignore the performance consideration while writing SELECTs against systems tables/views/dmvs etc. Recently a stored proc started Continue Reading..
How to generate Fibonacci Series in SQL Server? This is a very commonly asked interview question for SQL developers. I assume you must be knowing what is Fibonacci Series? In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Continue Reading..
Few times I have observed that developers directly consider the dynamic SQL option as a solution, when there is need to sort the result set on basis of user input variables/parameters. Let’s see how can we do the sorting using case when. Continue Reading..
Personally I am very strict to the datatypes, whether it’s for a column or parameter or just a variable. I don’t like if somebody choose them carelessly. Always the datatypes needs to used precisely. Make it as a coding standard or your Continue Reading..
Converting columns into rows in SQL Server is not a new thing, we often face this kind of scenarios. Lets say, there are values in different columns within a table and you want to perform some aggregations on those columns combining them all together or you Continue Reading..
I recently had a requirement to round off a decimal value to 0.5 either higher side or lower side. Example: 1.4 the higher side round off should be 1.5 and lower side should be 1 same way 2.7 should round off to Continue Reading..
There would be situations where in an application would have developed ages ago not considering to support multi time zone but later you realise and want to handle the same, when the application is already on production for couple of months or years. Recently I had Continue Reading..
A friend of mine asked me a very interesting question today, she wanted date output like “14th Mar 2016”. Immediately I answered her to use new FORMAT function eg: FORMAT (GETDATE(), ‘dd MMM yyyy’) or CONVERT(VARCHAR(10), GETDATE(), 13) which returns Continue Reading..
You must be wondering what is this correlated join in SQL Server? Let me clarify it’s not a type of join like INNER or OUTER, it is a kind of usage or play around with joins. Some call it derived join too. Anyway it Continue Reading..