SQL Server – NOT IN

It’s because of the way NOT IN works. To avoid these headaches (and for a faster query in many cases), I always prefer NOT EXISTS: SELECT * FROM Table1 t1 WHERE NOT EXISTS ( SELECT * FROM Table2 t2 WHERE t1.MAKE = t2.MAKE AND t1.MODEL = t2.MODEL AND t1.[Serial Number] = t2.[serial number]);

Getting offset of datetimeoffset in SQL Server

The DATEPART function has a tz option which returns the value’s UTC offset in int minutes. DATENAME also supports the tz option and returns the formatted UTC offset in the form [+-]HH:MM Note that a datetimeoffset value only contains a scalar UTC offset value, it does not contain any time-zone information at all (as multiple … Read more

MS SQL server casting without exception

This will default non-numerics to 0 and will not require another statement: SELECT CASE WHEN ISNUMERIC(myvarcharcolumn)=1 THEN CONVERT(float, REPLACE(LTRIM(RTRIM(myvarcharcolumn)), ‘,’, ‘.’)) ELSE 0 END AS myfloatcolumn The REPLACE() function call is used to change commas to periods. Commas are used in some cultures as a decimal separator (e.g., “1,25” instead of “1.25”), but unless your … Read more

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