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

DateTime2 vs DateTime in SQL Server

The MSDN documentation for datetime recommends using datetime2. Here is their recommendation: Use the time, date, datetime2 and datetimeoffset data types for new work. These types align with the SQL Standard. They are more portable. time, datetime2 and datetimeoffset provide more seconds precision. datetimeoffset provides time zone support for globally deployed applications. datetime2 has larger date range, a larger default fractional precision, and optional user-specified precision. Also depending on the user-specified … Read more

Why use a READ UNCOMMITTED isolation level?

This isolation level allows dirty reads. One transaction may see uncommitted changes made by some other transaction. To maintain the highest level of isolation, a DBMS usually acquires locks on data, which may result in a loss of concurrency and a high locking overhead. This isolation level relaxes this property. You may want to check … Read more

In SQL Server, what does “SET ANSI_NULLS ON” mean?

It means that no rows will be returned if @region is NULL, when used in your first example, even if there are rows in the table where Region is NULL. When ANSI_NULLS is on (which you should always set on anyway, since the option to not have it on is going to be removed in the future), any comparison operation where (at least) … Read more

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