Tuesday, July 25, 2017

SQL Generate Date from given date range



 WITH Dates AS (  
     SELECT  
      [Date] = CONVERT(DATETIME,'1-1-2017')  
     UNION ALL SELECT  
      [Date] = DATEADD(DAY, 1, [Date])  
     FROM  
      Dates  
     WHERE  
      Date < '12-31-2017'  
 ) SELECT [Date]  
 FROM Dates  
 OPTION (MAXRECURSION 1000)  



SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...