Try_Convert for SQL Server 2008 R2

When using XML in SQL Server you can try to cast to a data type and receive null values where the cast fails. declare @T table ( Col varchar(50) ) insert into @T values (‘1’), (‘1.1’), (‘1,1’), (‘1a’) select cast(” as xml).value(‘sql:column(“Col”) cast as xs:decimal ?’, ‘decimal(28,10)’) as Col from @T Result: Col ————- 1.0000000000 … Read more

Detect consecutive dates ranges using SQL

No joins or recursive CTEs needed. The standard gaps-and-island solution is to group by (value minus row_number), since that is invariant within a consecutive sequence. The start and end dates are just the MIN() and MAX() of the group. WITH t AS ( SELECT InfoDate d,ROW_NUMBER() OVER(ORDER BY InfoDate) i FROM @d GROUP BY InfoDate … Read more

Get most common value for each value of another column in SQL

It is now even simpler: PostgreSQL 9.4 introduced the mode() function: select mode() within group (order by food_id) from munch group by country returns (like user2247323’s example): country | mode ————– GB | 3 US | 1 See documentation here: https://wiki.postgresql.org/wiki/Aggregate_Mode https://www.postgresql.org/docs/current/static/functions-aggregate.html#FUNCTIONS-ORDEREDSET-TABLE

How can I determine type of mysql database : whether it is InnoDB or MyISAM?

To determine the storage engine being used by a table, you can use show table status. The Engine field in the results will show the database engine for the table. Alternately, you can select the engine field from information_schema.tables: select engine from information_schema.tables where table_schema=”schema_name” and table_name=”table_name” You can change between storage engines using alter … Read more

SQL_NO_CACHE does not work

The first query should use SQL_NO_CACHE to tell MySQL not to put the result into the cache. The second query uses the cache and the tells MySQL not to cache the result of that query, which does nothing. tl;dr – Reverse your queries.

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