SQL – The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

I have faced the same problem a week ago. The problem is with the time zone setting. Specify in other formats like mm/dd/yyyy (usually works). Specifying the date as 30/12/2013 resulted in the error for me. However, specifying it as mm/dd/yyyy format worked. If you need to convert your input the you can try looking into the CONVERT method. … Read more

How to group by month from Date field using sql

I would use this: This will group by the first of every month, so will give ‘20130101’. I generally prefer this method as it keeps dates as dates. Alternatively you could use something like this: It really depends what your desired output is. (Closing Year is not necessary in your example, but if the date range … Read more

SQL Server Insert if not exists

instead of below Code replace with Updated : (thanks to @Marc Durdin for pointing) Note that under high load, this will still sometimes fail, because a second connection can pass the IF NOT EXISTS test before the first connection executes the INSERT, i.e. a race condition. See stackoverflow.com/a/3791506/1836776 for a good answer on why even wrapping in a … Read more

Difference between numeric, float and decimal in SQL Server

use the float or real data types only if the precision provided by decimal (up to 38 digits) is insufficient Approximate numeric data types(see table 3.3) do not store the exact values specified for many numbers; they store an extremely close approximation of the value. (Technet) Avoid using float or real columns in WHERE clause search conditions, especially the = and <> operators. It is best to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)