How to script all Jobs in SQL Server Management Studio

cofee_book.pngWhen you need script more than one job from Microsoft SQL Server Management Studio by right click with mouse 'Script job', you will find you can script only one object and you cannot choose more than one job at once. Even with Shift or Ctrl key. Script all of then one by one can be really long and unpleasure work. But there is a an easy way, how to script all jobs (or objects like views, tables etc.).

How to recover unsaved T-SQL or previous version of altered view or store procedure

SQL icon baseWhen you alter view or stored procedure and you realize, previous version wasn't saved and you need it. Or you want recover SQL script immediately after management studio crash and you were lucky, that you run it at least once. There is a nice tricky way how do to it by SQL script without any 3rd party enhancement. 

How to find and remove hidden characters and invisible whitespace when LTrim, RTrim not work

SQL icon baseSometimes it can happen, that you compare two strings, which looks exactly sames, but they are processed as not equal. Also when you use SELECT DISTINCT and still there are rows that looks same, like DISTINCT is not working. Dimensional attribute in OLAP can return errors for duplicities even you used DISTINCT for dimension. This is the right time to search invisible/hidden characters in string.  RTrim and LTrim function not stripping whitespace.

How to get ISO Year for ISO Week

SQL icon baseIf you need calculate week number from date, you can use DATEPART with parameter ISO_WEEK. Unfortunately there is nothing like ISO YEAR parameter. In case you need to show YearWeek value in some report you have to take care about correct value manually.