Showing posts from July, 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)

Run all SQL files from a folder

Run all SQL files from  a folder you can follow the process that will save your time for executing SQL script

Copy this code in a notepad file and change the Server, Database, Username And Password value as your self and save it as a .bat file. copy the file in your SQL script folder and run this bat file.

REM REM development environment only!! REM pause for %%G in (*.sql) do sqlcmd /S "\SQLEXPRESS" /d "VSSPORT_DEV" -U "atiour" -P "atiour" -i"%%G" pause REM REM All Script Run Successfully REM